From f4d4f1b373f9e1760c0e3e89f2987866e10e2a1f Mon Sep 17 00:00:00 2001 From: PR Date: Mon, 21 Aug 2023 06:16:09 -0700 Subject: [PATCH 01/32] account validation --- .../account/account_channels_request.go | 18 ++++++++++----- .../account/account_currencies_request.go | 8 +++++++ model/client/account/account_info_request.go | 6 ++++- model/client/account/account_lines_request.go | 12 ++++++++++ model/client/account/account_nfts_request.go | 13 +++++++++++ .../client/account/account_objects_request.go | 13 +++++++++++ .../client/account/account_offers_request.go | 13 +++++++++++ .../account/account_transactions_request.go | 13 +++++++++++ model/transactions/types/address.go | 22 +++++++++++++++++++ 9 files changed, 111 insertions(+), 7 deletions(-) diff --git a/model/client/account/account_channels_request.go b/model/client/account/account_channels_request.go index 8c5f46d5..1e27b7d0 100644 --- a/model/client/account/account_channels_request.go +++ b/model/client/account/account_channels_request.go @@ -2,7 +2,7 @@ package account import ( "encoding/json" - "errors" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -21,12 +21,18 @@ func (*AccountChannelsRequest) Method() string { return "account_channels" } -// Validate method to be added to each request struct -func (a *AccountChannelsRequest) Validate() error { - if a.Account == "" { - return errors.New("no account ID specified") +func (r *AccountChannelsRequest) Validate() error { + if err := r.Account.Validate(); err != nil { + return err + } + if len(r.DestinationAccount) > 0 { + if err := r.DestinationAccount.Validate(); err != nil { + return err + } + } + if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { + return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") } - return nil } diff --git a/model/client/account/account_currencies_request.go b/model/client/account/account_currencies_request.go index b2ab4eea..9e74c10f 100644 --- a/model/client/account/account_currencies_request.go +++ b/model/client/account/account_currencies_request.go @@ -18,6 +18,14 @@ func (*AccountCurrenciesRequest) Method() string { return "account_currencies" } +func (r *AccountCurrenciesRequest) Validate() error { + if err := r.Account.Validate(); err != nil { + return err + } + + return nil +} + func (r *AccountCurrenciesRequest) UnmarshalJSON(data []byte) error { type acrHelper struct { Account types.Address `json:"account"` diff --git a/model/client/account/account_info_request.go b/model/client/account/account_info_request.go index 9506ba7d..7acb3dc0 100644 --- a/model/client/account/account_info_request.go +++ b/model/client/account/account_info_request.go @@ -20,7 +20,11 @@ func (*AccountInfoRequest) Method() string { return "account_info" } -func (*AccountInfoRequest) Validate() error { +func (r *AccountInfoRequest) Validate() error { + if err := r.Account.Validate(); err != nil { + return err + } + return nil } diff --git a/model/client/account/account_lines_request.go b/model/client/account/account_lines_request.go index 4cd9dd61..d6664b8a 100644 --- a/model/client/account/account_lines_request.go +++ b/model/client/account/account_lines_request.go @@ -2,6 +2,7 @@ package account import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -20,6 +21,17 @@ func (*AccountLinesRequest) Method() string { return "account_lines" } +func (r *AccountLinesRequest) Validate() error { + if err := r.Account.Validate(); err != nil { + return err + } + + if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { + return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + } + + return nil +} func (r *AccountLinesRequest) UnmarshalJSON(data []byte) error { type alrHelper struct { Account types.Address `json:"account"` diff --git a/model/client/account/account_nfts_request.go b/model/client/account/account_nfts_request.go index 15da7326..aa3dda54 100644 --- a/model/client/account/account_nfts_request.go +++ b/model/client/account/account_nfts_request.go @@ -2,6 +2,7 @@ package account import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -19,6 +20,18 @@ func (*AccountNFTsRequest) Method() string { return "account_nfts" } +func (r *AccountNFTsRequest) Validate() error { + if err := r.Account.Validate(); err != nil { + return err + } + + if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { + return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + } + + return nil +} + func (r *AccountNFTsRequest) UnmarshalJSON(data []byte) error { type anrHelper struct { Account types.Address `json:"account"` diff --git a/model/client/account/account_objects_request.go b/model/client/account/account_objects_request.go index 9111341e..c046d5e7 100644 --- a/model/client/account/account_objects_request.go +++ b/model/client/account/account_objects_request.go @@ -2,6 +2,7 @@ package account import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -35,6 +36,18 @@ func (*AccountObjectsRequest) Method() string { return "account_objects" } +func (r *AccountObjectsRequest) Validate() error { + if err := r.Account.Validate(); err != nil { + return err + } + + if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { + return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + } + + return nil +} + func (r *AccountObjectsRequest) UnmarshalJSON(data []byte) error { type aorHelper struct { Account types.Address `json:"account"` diff --git a/model/client/account/account_offers_request.go b/model/client/account/account_offers_request.go index 0056cbef..9b4bd4f4 100644 --- a/model/client/account/account_offers_request.go +++ b/model/client/account/account_offers_request.go @@ -2,6 +2,7 @@ package account import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -20,6 +21,18 @@ func (*AccountOffersRequest) Method() string { return "account_offers" } +func (r *AccountOffersRequest) Validate() error { + if err := r.Account.Validate(); err != nil { + return err + } + + if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { + return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + } + + return nil +} + func (r *AccountOffersRequest) UnmarshalJSON(data []byte) error { type aorHelper struct { Account types.Address `json:"account"` diff --git a/model/client/account/account_transactions_request.go b/model/client/account/account_transactions_request.go index 49c2c8c1..e6bb23dd 100644 --- a/model/client/account/account_transactions_request.go +++ b/model/client/account/account_transactions_request.go @@ -2,6 +2,7 @@ package account import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -23,6 +24,18 @@ func (*AccountTransactionsRequest) Method() string { return "account_tx" } +func (r *AccountTransactionsRequest) Validate() error { + if err := r.Account.Validate(); err != nil { + return err + } + + if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { + return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + } + + return nil +} + func (r *AccountTransactionsRequest) UnmarshalJSON(data []byte) error { type atrHelper struct { Account types.Address `json:"account"` diff --git a/model/transactions/types/address.go b/model/transactions/types/address.go index 1337a228..f6f2ec8c 100644 --- a/model/transactions/types/address.go +++ b/model/transactions/types/address.go @@ -1,3 +1,25 @@ package types +import ( + "fmt" + "strings" +) + type Address string + +func (a Address) Validate() error { + characters := []string{"0", "O", "I", "l"} + if len(a) < 25 || len(a) > 35 { + return fmt.Errorf("invalid xrpl address length") + } + if a[0] != 'r' { + return fmt.Errorf("invalid xrpl address prefix '%c'", a[0]) + } + for _, c := range characters { + if strings.Contains(string(a), c) { + return fmt.Errorf("xrpl address contains invalid character '%s'", c) + } + } + // TODO checksum + return nil +} From 294baa68a58d19c58b8ba7d9e71fd6212b35d7e7 Mon Sep 17 00:00:00 2001 From: PR Date: Tue, 22 Aug 2023 04:24:10 -0700 Subject: [PATCH 02/32] admin validation --- model/client/admin/data/can_delete_request.go | 4 ++++ .../client/admin/data/crawl_shards_request.go | 10 ++++++++++ .../admin/data/download_shard_request.go | 4 ++++ .../admin/data/ledger_cleaner_request.go | 4 ++++ .../admin/data/ledger_request_request.go | 4 ++++ model/client/admin/data/log_level_request.go | 19 +++++++++++++++++-- model/client/admin/data/logrotate_request.go | 4 ++++ .../admin/data/node_to_shard_request.go | 10 ++++++++++ .../admin/key/validation_create_request.go | 4 ++++ .../admin/key/wallet_propose_request.go | 4 ++++ model/client/admin/peer/connect_request.go | 4 ++++ .../peer/peer_reservations_add_request.go | 4 ++++ .../peer/peer_reservations_del_request.go | 4 ++++ .../peer/peer_reservations_list_request.go | 4 ++++ model/client/admin/peer/peers_request.go | 4 ++++ .../admin/server/ledger_accept_request.go | 4 ++++ model/client/admin/server/stop_request.go | 4 ++++ .../client/admin/signing/sign_for_request.go | 13 +++++++++++++ model/client/admin/signing/sign_request.go | 9 +++++++++ .../admin/status/consensus_info_request.go | 4 ++++ model/client/admin/status/feature_request.go | 4 ++++ .../client/admin/status/fetch_info_request.go | 4 ++++ .../client/admin/status/get_counts_request.go | 4 ++++ .../admin/status/validator_info_request.go | 4 ++++ .../status/validator_list_sites_request.go | 4 ++++ .../client/admin/status/validators_request.go | 4 ++++ 26 files changed, 143 insertions(+), 2 deletions(-) diff --git a/model/client/admin/data/can_delete_request.go b/model/client/admin/data/can_delete_request.go index 9d1f615d..90cf22b1 100644 --- a/model/client/admin/data/can_delete_request.go +++ b/model/client/admin/data/can_delete_request.go @@ -14,6 +14,10 @@ func (*CanDeleteRequest) Method() string { return "can_delete" } +func (*CanDeleteRequest) Validate() error { + return nil +} + func (r *CanDeleteRequest) UnmarshalJSON(data []byte) error { type cdHelper struct { CanDelete json.RawMessage `json:"can_delete"` diff --git a/model/client/admin/data/crawl_shards_request.go b/model/client/admin/data/crawl_shards_request.go index eb96b4d9..1ddd8760 100644 --- a/model/client/admin/data/crawl_shards_request.go +++ b/model/client/admin/data/crawl_shards_request.go @@ -1,5 +1,7 @@ package data +import "fmt" + type CrawlShardsRequest struct { PublicKey bool `json:"public_key,omitempty"` Limit int `json:"limit,omitempty"` @@ -8,3 +10,11 @@ type CrawlShardsRequest struct { func (*CrawlShardsRequest) Method() string { return "crawl_shards" } + +func (r *CrawlShardsRequest) Validate() error { + if r.Limit < 0 || r.Limit > 3 { + return fmt.Errorf("crawl shards request: invalid limit, must be 0 <= limit <= 3") + } + + return nil +} diff --git a/model/client/admin/data/download_shard_request.go b/model/client/admin/data/download_shard_request.go index ae35b5cf..4ad3d0db 100644 --- a/model/client/admin/data/download_shard_request.go +++ b/model/client/admin/data/download_shard_request.go @@ -14,3 +14,7 @@ type ShardDescriptor struct { func (*DownloadShardRequest) Method() string { return "download_shard" } + +func (*DownloadShardRequest) Validate() error { + return nil +} diff --git a/model/client/admin/data/ledger_cleaner_request.go b/model/client/admin/data/ledger_cleaner_request.go index f7adb3e7..15c32e57 100644 --- a/model/client/admin/data/ledger_cleaner_request.go +++ b/model/client/admin/data/ledger_cleaner_request.go @@ -15,3 +15,7 @@ type LedgerCleanerRequest struct { func (*LedgerCleanerRequest) Method() string { return "ledger_cleaner" } + +func (*LedgerCleanerRequest) Validate() error { + return nil +} diff --git a/model/client/admin/data/ledger_request_request.go b/model/client/admin/data/ledger_request_request.go index 6c7dedfc..7a74c2ef 100644 --- a/model/client/admin/data/ledger_request_request.go +++ b/model/client/admin/data/ledger_request_request.go @@ -10,3 +10,7 @@ type LedgerRequestRequest struct { func (*LedgerRequest) Method() string { return "ledger_request" } + +func (*LedgerRequest) Validate() error { + return nil +} diff --git a/model/client/admin/data/log_level_request.go b/model/client/admin/data/log_level_request.go index ab75171e..4e114adc 100644 --- a/model/client/admin/data/log_level_request.go +++ b/model/client/admin/data/log_level_request.go @@ -1,10 +1,25 @@ package data +const ( + Fatal LogSeverity = "fatal" + Error LogSeverity = "error" + Warn LogSeverity = "warn" + Info LogSeverity = "info" + Debug LogSeverity = "debug" + Trace LogSeverity = "trace" +) + +type LogSeverity string + type LogLevelRequest struct { - Severity string `json:"severity,omitempty"` - Partition string `json:"partition,omitempty"` + Severity LogSeverity `json:"severity,omitempty"` + Partition string `json:"partition,omitempty"` } func (*LogLevelRequest) Method() string { return "log_level" } + +func (*LogLevelRequest) Validate() error { + return nil +} diff --git a/model/client/admin/data/logrotate_request.go b/model/client/admin/data/logrotate_request.go index 2e4cbd70..1df50e5d 100644 --- a/model/client/admin/data/logrotate_request.go +++ b/model/client/admin/data/logrotate_request.go @@ -6,3 +6,7 @@ type LogrotateRequest struct { func (*LogrotateRequest) Method() string { return "logrotate" } + +func (*LogrotateRequest) Validate() error { + return nil +} diff --git a/model/client/admin/data/node_to_shard_request.go b/model/client/admin/data/node_to_shard_request.go index 850e3167..2f37e2da 100644 --- a/model/client/admin/data/node_to_shard_request.go +++ b/model/client/admin/data/node_to_shard_request.go @@ -1,5 +1,7 @@ package data +import "fmt" + type NodeToShardRequest struct { Action string `json:"action"` } @@ -7,3 +9,11 @@ type NodeToShardRequest struct { func (*NodeToShardRequest) Method() string { return "node_to_shard" } + +func (r *NodeToShardRequest) Validate() error { + if r.Action != "start" && r.Action != "stop" && r.Action != "status" { + return fmt.Errorf("node to shard request: invalid action '%s'", r.Action) + } + + return nil +} diff --git a/model/client/admin/key/validation_create_request.go b/model/client/admin/key/validation_create_request.go index 4f71ebfc..0a1ca127 100644 --- a/model/client/admin/key/validation_create_request.go +++ b/model/client/admin/key/validation_create_request.go @@ -7,3 +7,7 @@ type ValidationCreateRequest struct { func (*ValidationCreateRequest) Method() string { return "validation_create" } + +func (*ValidationCreateRequest) Validate() error { + return nil +} diff --git a/model/client/admin/key/wallet_propose_request.go b/model/client/admin/key/wallet_propose_request.go index 80864185..e61e6fa7 100644 --- a/model/client/admin/key/wallet_propose_request.go +++ b/model/client/admin/key/wallet_propose_request.go @@ -10,3 +10,7 @@ type WalletProposeRequest struct { func (*WalletProposeRequest) Method() string { return "wallet_propose" } + +func (*WalletProposeRequest) Validate() error { + return nil +} diff --git a/model/client/admin/peer/connect_request.go b/model/client/admin/peer/connect_request.go index 334e062d..c8acf829 100644 --- a/model/client/admin/peer/connect_request.go +++ b/model/client/admin/peer/connect_request.go @@ -8,3 +8,7 @@ type ConnectRequest struct { func (*ConnectRequest) Method() string { return "connect" } + +func (*ConnectRequest) Validate() error { + return nil +} diff --git a/model/client/admin/peer/peer_reservations_add_request.go b/model/client/admin/peer/peer_reservations_add_request.go index b0ff2111..e763ec87 100644 --- a/model/client/admin/peer/peer_reservations_add_request.go +++ b/model/client/admin/peer/peer_reservations_add_request.go @@ -8,3 +8,7 @@ type PeerReservationAddRequest struct { func (*PeerReservationAddRequest) Method() string { return "peer_reservations_add" } + +func (*PeerReservationAddRequest) Validate() error { + return nil +} diff --git a/model/client/admin/peer/peer_reservations_del_request.go b/model/client/admin/peer/peer_reservations_del_request.go index eefae290..f2262fbc 100644 --- a/model/client/admin/peer/peer_reservations_del_request.go +++ b/model/client/admin/peer/peer_reservations_del_request.go @@ -7,3 +7,7 @@ type PeerReservationDelRequest struct { func (*PeerReservationDelRequest) Method() string { return "peer_reservations_del" } + +func (*PeerReservationDelRequest) Validate() error { + return nil +} diff --git a/model/client/admin/peer/peer_reservations_list_request.go b/model/client/admin/peer/peer_reservations_list_request.go index 54c991a2..c2af410c 100644 --- a/model/client/admin/peer/peer_reservations_list_request.go +++ b/model/client/admin/peer/peer_reservations_list_request.go @@ -6,3 +6,7 @@ type PeerReservationsListRequest struct { func (*PeerReservationsListRequest) Method() string { return "peer_reservations_list" } + +func (*PeerReservationsListRequest) Validate() error { + return nil +} diff --git a/model/client/admin/peer/peers_request.go b/model/client/admin/peer/peers_request.go index c1ceafa5..2e4ab33b 100644 --- a/model/client/admin/peer/peers_request.go +++ b/model/client/admin/peer/peers_request.go @@ -6,3 +6,7 @@ type PeersRequest struct { func (*PeersRequest) Method() string { return "peers" } + +func (*PeersRequest) Validate() error { + return nil +} diff --git a/model/client/admin/server/ledger_accept_request.go b/model/client/admin/server/ledger_accept_request.go index 550f5089..9804ddfe 100644 --- a/model/client/admin/server/ledger_accept_request.go +++ b/model/client/admin/server/ledger_accept_request.go @@ -6,3 +6,7 @@ type LedgerAcceptRequest struct { func (*LedgerAcceptRequest) Method() string { return "leder_accept" } + +func (*LedgerAcceptRequest) Validate() error { + return nil +} diff --git a/model/client/admin/server/stop_request.go b/model/client/admin/server/stop_request.go index 9083f4c1..dd2e3127 100644 --- a/model/client/admin/server/stop_request.go +++ b/model/client/admin/server/stop_request.go @@ -6,3 +6,7 @@ type StopRequest struct { func (*StopRequest) Method() string { return "stop" } + +func (*StopRequest) Validate() error { + return nil +} diff --git a/model/client/admin/signing/sign_for_request.go b/model/client/admin/signing/sign_for_request.go index 046f9da0..b4f56219 100644 --- a/model/client/admin/signing/sign_for_request.go +++ b/model/client/admin/signing/sign_for_request.go @@ -2,6 +2,7 @@ package signing import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/transactions" "github.com/xyield/xrpl-go/model/transactions/types" @@ -21,6 +22,18 @@ func (*SignForRequest) Method() string { return "sign_for" } +func (r *SignForRequest) Validate() error { + if err := r.Account.Validate(); err != nil { + return fmt.Errorf("sign for request: %w", err) + } + + if r.TxJson == nil { + return fmt.Errorf("sign for request: empty tx") + } + + return nil +} + func (r *SignForRequest) UnmarshalJSON(data []byte) error { type srHelper struct { Account types.Address `json:"account"` diff --git a/model/client/admin/signing/sign_request.go b/model/client/admin/signing/sign_request.go index 6a2b66eb..21f1bd82 100644 --- a/model/client/admin/signing/sign_request.go +++ b/model/client/admin/signing/sign_request.go @@ -2,6 +2,7 @@ package signing import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/transactions" ) @@ -23,6 +24,14 @@ func (*SignRequest) Method() string { return "sign" } +func (r *SignRequest) Validate() error { + if r.TxJson == nil { + return fmt.Errorf("sign request: empty tx") + } + + return nil +} + func (r *SignRequest) UnmarshalJSON(data []byte) error { type srHelper struct { TxJson json.RawMessage `json:"tx_json"` diff --git a/model/client/admin/status/consensus_info_request.go b/model/client/admin/status/consensus_info_request.go index 8b9c9677..bbaef342 100644 --- a/model/client/admin/status/consensus_info_request.go +++ b/model/client/admin/status/consensus_info_request.go @@ -6,3 +6,7 @@ type ConsensusInfoRequest struct { func (*ConsensusInfoRequest) Method() string { return "consensus_info" } + +func (*ConsensusInfoRequest) Validate() error { + return nil +} diff --git a/model/client/admin/status/feature_request.go b/model/client/admin/status/feature_request.go index 4daa8148..572b17d9 100644 --- a/model/client/admin/status/feature_request.go +++ b/model/client/admin/status/feature_request.go @@ -8,3 +8,7 @@ type FeatureRequest struct { func (*FeatureRequest) Method() string { return "feature" } + +func (*FeatureRequest) Validate() error { + return nil +} diff --git a/model/client/admin/status/fetch_info_request.go b/model/client/admin/status/fetch_info_request.go index c671a759..0ed1e245 100644 --- a/model/client/admin/status/fetch_info_request.go +++ b/model/client/admin/status/fetch_info_request.go @@ -7,3 +7,7 @@ type FetchInfoRequest struct { func (*FetchInfoRequest) Method() string { return "fetch_info" } + +func (*FetchInfoRequest) Validate() error { + return nil +} diff --git a/model/client/admin/status/get_counts_request.go b/model/client/admin/status/get_counts_request.go index 2e72847a..59e236f0 100644 --- a/model/client/admin/status/get_counts_request.go +++ b/model/client/admin/status/get_counts_request.go @@ -7,3 +7,7 @@ type GetCountsRequest struct { func (*GetCountsRequest) Method() string { return "get_counts" } + +func (*GetCountsRequest) Validate() error { + return nil +} diff --git a/model/client/admin/status/validator_info_request.go b/model/client/admin/status/validator_info_request.go index 0ab6ad8b..6fa7ac3d 100644 --- a/model/client/admin/status/validator_info_request.go +++ b/model/client/admin/status/validator_info_request.go @@ -6,3 +6,7 @@ type ValidatorInfoRequest struct { func (*ValidatorInfoRequest) Method() string { return "validator_info" } + +func (*ValidatorInfoRequest) Validate() error { + return nil +} diff --git a/model/client/admin/status/validator_list_sites_request.go b/model/client/admin/status/validator_list_sites_request.go index 6df3a907..430cd55f 100644 --- a/model/client/admin/status/validator_list_sites_request.go +++ b/model/client/admin/status/validator_list_sites_request.go @@ -6,3 +6,7 @@ type ValidatorListSitesRequest struct { func (*ValidatorListSitesRequest) Method() string { return "validator_list_sites" } + +func (*ValidatorListSitesRequest) Validate() error { + return nil +} diff --git a/model/client/admin/status/validators_request.go b/model/client/admin/status/validators_request.go index 354f344f..584a2fdc 100644 --- a/model/client/admin/status/validators_request.go +++ b/model/client/admin/status/validators_request.go @@ -6,3 +6,7 @@ type ValidatorsRequest struct { func (*ValidatorsRequest) Method() string { return "validators" } + +func (*ValidatorsRequest) Validate() error { + return nil +} From f3c535298786feca3e8adb9a8f9b4cb1807f133d Mon Sep 17 00:00:00 2001 From: PR Date: Tue, 22 Aug 2023 04:31:21 -0700 Subject: [PATCH 03/32] improve error --- model/client/account/account_channels_request.go | 8 +++----- model/client/account/account_currencies_request.go | 3 ++- model/client/account/account_info_request.go | 3 ++- model/client/account/account_lines_request.go | 4 ++-- model/client/account/account_nfts_request.go | 6 +++--- model/client/account/account_objects_request.go | 4 ++-- model/client/account/account_offers_request.go | 4 ++-- model/client/account/account_transactions_request.go | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/model/client/account/account_channels_request.go b/model/client/account/account_channels_request.go index 1e27b7d0..14eb5e58 100644 --- a/model/client/account/account_channels_request.go +++ b/model/client/account/account_channels_request.go @@ -23,16 +23,14 @@ func (*AccountChannelsRequest) Method() string { func (r *AccountChannelsRequest) Validate() error { if err := r.Account.Validate(); err != nil { - return err + return fmt.Errorf("account channels request: %w", err) } if len(r.DestinationAccount) > 0 { if err := r.DestinationAccount.Validate(); err != nil { - return err + return fmt.Errorf("account channels request: %w", err) } } - if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { - return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") - } + return nil } diff --git a/model/client/account/account_currencies_request.go b/model/client/account/account_currencies_request.go index 9e74c10f..a4d71205 100644 --- a/model/client/account/account_currencies_request.go +++ b/model/client/account/account_currencies_request.go @@ -2,6 +2,7 @@ package account import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -20,7 +21,7 @@ func (*AccountCurrenciesRequest) Method() string { func (r *AccountCurrenciesRequest) Validate() error { if err := r.Account.Validate(); err != nil { - return err + return fmt.Errorf("account currencies request: %w", err) } return nil diff --git a/model/client/account/account_info_request.go b/model/client/account/account_info_request.go index 7acb3dc0..3c5cc4dd 100644 --- a/model/client/account/account_info_request.go +++ b/model/client/account/account_info_request.go @@ -2,6 +2,7 @@ package account import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -22,7 +23,7 @@ func (*AccountInfoRequest) Method() string { func (r *AccountInfoRequest) Validate() error { if err := r.Account.Validate(); err != nil { - return err + return fmt.Errorf("account info request: %w", err) } return nil diff --git a/model/client/account/account_lines_request.go b/model/client/account/account_lines_request.go index d6664b8a..825466f0 100644 --- a/model/client/account/account_lines_request.go +++ b/model/client/account/account_lines_request.go @@ -23,11 +23,11 @@ func (*AccountLinesRequest) Method() string { func (r *AccountLinesRequest) Validate() error { if err := r.Account.Validate(); err != nil { - return err + return fmt.Errorf("account lines request: %w", err) } if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { - return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + return fmt.Errorf("account lines request: invalid limit, must be 10 <= limit <= 400") } return nil diff --git a/model/client/account/account_nfts_request.go b/model/client/account/account_nfts_request.go index aa3dda54..947e564b 100644 --- a/model/client/account/account_nfts_request.go +++ b/model/client/account/account_nfts_request.go @@ -22,11 +22,11 @@ func (*AccountNFTsRequest) Method() string { func (r *AccountNFTsRequest) Validate() error { if err := r.Account.Validate(); err != nil { - return err + return fmt.Errorf("account nfts request: %w", err) } - if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { - return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + if r.Limit != 0 && (r.Limit < 20 || r.Limit > 400) { + return fmt.Errorf("account nfts request: invalid limit, must be 20 <= limit <= 400") } return nil diff --git a/model/client/account/account_objects_request.go b/model/client/account/account_objects_request.go index c046d5e7..9fcad492 100644 --- a/model/client/account/account_objects_request.go +++ b/model/client/account/account_objects_request.go @@ -38,11 +38,11 @@ func (*AccountObjectsRequest) Method() string { func (r *AccountObjectsRequest) Validate() error { if err := r.Account.Validate(); err != nil { - return err + return fmt.Errorf("account objects request: %w", err) } if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { - return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + return fmt.Errorf("account objects request: invalid limit, must be 10 <= limit <= 400") } return nil diff --git a/model/client/account/account_offers_request.go b/model/client/account/account_offers_request.go index 9b4bd4f4..5b8db29f 100644 --- a/model/client/account/account_offers_request.go +++ b/model/client/account/account_offers_request.go @@ -23,11 +23,11 @@ func (*AccountOffersRequest) Method() string { func (r *AccountOffersRequest) Validate() error { if err := r.Account.Validate(); err != nil { - return err + return fmt.Errorf("account offers request: %w", err) } if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { - return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + return fmt.Errorf("account offers request: invalid limit, must be 10 <= limit <= 400") } return nil diff --git a/model/client/account/account_transactions_request.go b/model/client/account/account_transactions_request.go index e6bb23dd..3373dee5 100644 --- a/model/client/account/account_transactions_request.go +++ b/model/client/account/account_transactions_request.go @@ -26,11 +26,11 @@ func (*AccountTransactionsRequest) Method() string { func (r *AccountTransactionsRequest) Validate() error { if err := r.Account.Validate(); err != nil { - return err + return fmt.Errorf("account transactions request: %w", err) } if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { - return fmt.Errorf("invalid limit, must be 10 <= limit <= 400") + return fmt.Errorf("account transactions request: invalid limit, must be 10 <= limit <= 400") } return nil From 651a7e49bf2afc94e7975a47324e5ae6b4d33c5a Mon Sep 17 00:00:00 2001 From: PR Date: Tue, 22 Aug 2023 04:35:07 -0700 Subject: [PATCH 04/32] channel validation --- model/client/channel/channel_authorize_request.go | 8 ++++++++ model/client/channel/channel_verify_request.go | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/model/client/channel/channel_authorize_request.go b/model/client/channel/channel_authorize_request.go index f4af62a8..26513d26 100644 --- a/model/client/channel/channel_authorize_request.go +++ b/model/client/channel/channel_authorize_request.go @@ -20,6 +20,14 @@ func (*ChannelAuthorizeRequest) Method() string { return "channel_authorize" } +func (r *ChannelAuthorizeRequest) Validate() error { + if r.ChannelID == "" { + return fmt.Errorf("channel authorize request: missing channel id") + } + + return nil +} + // do not allow secrets to be printed func (c *ChannelAuthorizeRequest) Format(s fmt.State, v rune) { type fHelper struct { diff --git a/model/client/channel/channel_verify_request.go b/model/client/channel/channel_verify_request.go index d3e54eff..4a4b18a8 100644 --- a/model/client/channel/channel_verify_request.go +++ b/model/client/channel/channel_verify_request.go @@ -12,3 +12,7 @@ type ChannelVerifyRequest struct { func (*ChannelVerifyRequest) Method() string { return "channel_verify" } + +func (*ChannelVerifyRequest) Validate() error { + return nil +} From ec0b614035d25380870b817378ca796575da6ca2 Mon Sep 17 00:00:00 2001 From: PR Date: Tue, 22 Aug 2023 04:37:33 -0700 Subject: [PATCH 05/32] clio validation --- model/client/clio/ledger_request.go | 4 ++++ model/client/clio/nft_info_request.go | 4 ++++ model/client/clio/server_info_request.go | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/model/client/clio/ledger_request.go b/model/client/clio/ledger_request.go index e8ad6a88..db0fa279 100644 --- a/model/client/clio/ledger_request.go +++ b/model/client/clio/ledger_request.go @@ -23,6 +23,10 @@ func (*LedgerRequest) Method() string { return "ledger" } +func (*LedgerRequest) Validate() error { + return nil +} + func (r *LedgerRequest) UnmarshalJSON(data []byte) error { type lrHelper struct { LedgerHash common.LedgerHash `json:"ledger_hash"` diff --git a/model/client/clio/nft_info_request.go b/model/client/clio/nft_info_request.go index 0ada2376..c12f2369 100644 --- a/model/client/clio/nft_info_request.go +++ b/model/client/clio/nft_info_request.go @@ -17,6 +17,10 @@ func (*NFTInfoRequest) Method() string { return "nft_info" } +func (*NFTInfoRequest) Validate() error { + return nil +} + func (r *NFTInfoRequest) UnmarshalJSON(data []byte) error { type nirHelper struct { NFTokenID types.NFTokenID `json:"nft_id"` diff --git a/model/client/clio/server_info_request.go b/model/client/clio/server_info_request.go index a285d90f..215efeca 100644 --- a/model/client/clio/server_info_request.go +++ b/model/client/clio/server_info_request.go @@ -6,3 +6,7 @@ type ServerInfoRequest struct { func (*ServerInfoRequest) Method() string { return "server_info" } + +func (*ServerInfoRequest) Validate() error { + return nil +} From efbcd0d5a7733c27c60dfe54785ab4d470b7ca47 Mon Sep 17 00:00:00 2001 From: PR Date: Thu, 7 Sep 2023 12:40:46 -0700 Subject: [PATCH 06/32] ledger request validation --- model/client/ledger/ledger_closed_request.go | 4 + model/client/ledger/ledger_current_request.go | 4 + model/client/ledger/ledger_data_request.go | 5 + model/client/ledger/ledger_entry_request.go | 161 ++++++++++++++++-- model/client/ledger/ledger_request.go | 4 + 5 files changed, 160 insertions(+), 18 deletions(-) diff --git a/model/client/ledger/ledger_closed_request.go b/model/client/ledger/ledger_closed_request.go index d58da25e..f8d8c456 100644 --- a/model/client/ledger/ledger_closed_request.go +++ b/model/client/ledger/ledger_closed_request.go @@ -6,3 +6,7 @@ type LedgerClosedRequest struct { func (*LedgerClosedRequest) Method() string { return "ledger_closed" } + +func (*LedgerClosedRequest) Validate() error { + return nil +} diff --git a/model/client/ledger/ledger_current_request.go b/model/client/ledger/ledger_current_request.go index b9c40317..687f9682 100644 --- a/model/client/ledger/ledger_current_request.go +++ b/model/client/ledger/ledger_current_request.go @@ -6,3 +6,7 @@ type LedgerCurrentRequest struct { func (*LedgerCurrentRequest) Method() string { return "ledger_current" } + +func (*LedgerCurrentRequest) Validate() error { + return nil +} diff --git a/model/client/ledger/ledger_data_request.go b/model/client/ledger/ledger_data_request.go index 6fa6bc67..dfa6f591 100644 --- a/model/client/ledger/ledger_data_request.go +++ b/model/client/ledger/ledger_data_request.go @@ -44,3 +44,8 @@ func (r *LedgerDataRequest) UnmarshalJSON(data []byte) error { return nil } + +func (r *LedgerDataRequest) Validate() error { + // invalid limits are overwritten server-side + return nil +} diff --git a/model/client/ledger/ledger_entry_request.go b/model/client/ledger/ledger_entry_request.go index b6baaae2..24f69515 100644 --- a/model/client/ledger/ledger_entry_request.go +++ b/model/client/ledger/ledger_entry_request.go @@ -2,6 +2,7 @@ package ledger import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -15,7 +16,7 @@ type LedgerEntryRequest struct { AccountRoot types.Address `json:"account_root,omitempty"` Directory EntryRequestOrString `json:"directory,omitempty"` Offer EntryRequestOrString `json:"offer,omitempty"` - RippleState EntryRequestOrString `json:"ripple_state,omitempty"` + RippleState *RippleStateEntryReq `json:"ripple_state,omitempty"` Check string `json:"check,omitempty"` Escrow EntryRequestOrString `json:"escrow,omitempty"` PaymentChannel string `json:"payment_channel,omitempty"` @@ -23,12 +24,92 @@ type LedgerEntryRequest struct { Ticket EntryRequestOrString `json:"ticket,omitempty"` } +func (*LedgerEntryRequest) Method() string { + return "ledger_entry" +} + +func (r *LedgerEntryRequest) Validate() error { + setCount := 0 + + if r.Index != "" { + setCount++ + } + + if r.AccountRoot != "" { + setCount++ + if err := r.AccountRoot.Validate(); err != nil { + return fmt.Errorf("ledger entry account root: %w", err) + } + } + + if r.Directory != nil { + setCount++ + if err := r.Directory.Validate(); err != nil { + return fmt.Errorf("ledger entry directory: %w", err) + } + } + + if r.Offer != nil { + setCount++ + if err := r.Offer.Validate(); err != nil { + return fmt.Errorf("ledger entry offer: %w", err) + } + } + + if r.RippleState != nil { + setCount++ + if err := r.Offer.Validate(); err != nil { + return fmt.Errorf("ledger entry ripple state: %w", err) + } + } + + if r.Check != "" { + setCount++ + } + + if r.Escrow != nil { + setCount++ + if err := r.Escrow.Validate(); err != nil { + return fmt.Errorf("ledger entry escrow: %w", err) + } + } + + if r.PaymentChannel != "" { + setCount++ + } + + if r.DepositPreauth != nil { + setCount++ + if err := r.DepositPreauth.Validate(); err != nil { + return fmt.Errorf("ledger entry deposit preauth: %w", err) + } + } + + if r.Ticket != nil { + setCount++ + if err := r.Ticket.Validate(); err != nil { + return fmt.Errorf("ledger entry ticket: %w", err) + } + } + + if setCount != 1 { + return fmt.Errorf("ledger entry: exactly one ledger entry object may be requested") + } + + return nil +} + type EntryRequestOrString interface { LedgerEntryRequestField() + Validate() error } type EntryString string +func (EntryString) Validate() error { + return nil +} + func (EntryString) LedgerEntryRequestField() {} type DirectoryEntryReq struct { @@ -37,6 +118,10 @@ type DirectoryEntryReq struct { Owner string `json:"owner,omitempty"` } +func (*DirectoryEntryReq) Validate() error { + return nil +} + func (*DirectoryEntryReq) LedgerEntryRequestField() {} type OfferEntryReq struct { @@ -46,6 +131,13 @@ type OfferEntryReq struct { func (*OfferEntryReq) LedgerEntryRequestField() {} +func (r *OfferEntryReq) Validate() error { + if err := r.Account.Validate(); err != nil { + return fmt.Errorf("offer entry: %w", err) + } + return nil +} + type RippleStateEntryReq struct { Accounts []types.Address `json:"accounts"` Currency string `json:"currency"` @@ -53,6 +145,18 @@ type RippleStateEntryReq struct { func (*RippleStateEntryReq) LedgerEntryRequestField() {} +func (r *RippleStateEntryReq) Validate() error { + if len(r.Accounts) != 2 { + return fmt.Errorf("ripple state entry requires two accounts") + } + for _, a := range r.Accounts { + if err := a.Validate(); err != nil { + return fmt.Errorf("ripple state entry: %w", err) + } + } + return nil +} + type EscrowEntryReq struct { Owner types.Address `json:"owner"` Seq uint `json:"seq"` @@ -60,6 +164,13 @@ type EscrowEntryReq struct { func (*EscrowEntryReq) LedgerEntryRequestField() {} +func (r *EscrowEntryReq) Validate() error { + if err := r.Owner.Validate(); err != nil { + return fmt.Errorf("escrow entry: %w", err) + } + return nil +} + type DepositPreauthEntryReq struct { Owner types.Address `json:"owner"` Authorized types.Address `json:"authorized"` @@ -67,6 +178,16 @@ type DepositPreauthEntryReq struct { func (*DepositPreauthEntryReq) LedgerEntryRequestField() {} +func (r *DepositPreauthEntryReq) Validate() error { + if err := r.Owner.Validate(); err != nil { + return fmt.Errorf("deposit preauth entry owner: %w", err) + } + if err := r.Authorized.Validate(); err != nil { + return fmt.Errorf("deposit preauth entry authorized: %w", err) + } + return nil +} + type TicketEntryReq struct { Account types.Address `json:"account"` TicketSeq int `json:"ticket_seq"` @@ -74,6 +195,13 @@ type TicketEntryReq struct { func (*TicketEntryReq) LedgerEntryRequestField() {} +func (r *TicketEntryReq) Validate() error { + if err := r.Account.Validate(); err != nil { + return fmt.Errorf("ticket entry: %w", err) + } + return nil +} + func parseEntryRequestField(data []byte, target EntryRequestOrString) (EntryRequestOrString, error) { if len(data) == 0 { return nil, nil @@ -89,19 +217,19 @@ func parseEntryRequestField(data []byte, target EntryRequestOrString) (EntryRequ func (r *LedgerEntryRequest) UnmarshalJSON(data []byte) error { type lerHelper struct { - Binary bool `json:"binary,omitempty"` - LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"` - LedgerIndex json.RawMessage `json:"ledger_index,omitempty"` - Index string `json:"index,omitempty"` - AccountRoot types.Address `json:"account_root,omitempty"` - Directory json.RawMessage `json:"directory,omitempty"` - Offer json.RawMessage `json:"offer,omitempty"` - RippleState json.RawMessage `json:"ripple_state,omitempty"` - Check string `json:"check,omitempty"` - Escrow json.RawMessage `json:"escrow,omitempty"` - PaymentChannel string `json:"payment_channel,omitempty"` - DepositPreauth json.RawMessage `json:"deposit_preauth,omitempty"` - Ticket json.RawMessage `json:"ticket,omitempty"` + Binary bool `json:"binary,omitempty"` + LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"` + LedgerIndex json.RawMessage `json:"ledger_index,omitempty"` + Index string `json:"index,omitempty"` + AccountRoot types.Address `json:"account_root,omitempty"` + Directory json.RawMessage `json:"directory,omitempty"` + Offer json.RawMessage `json:"offer,omitempty"` + RippleState *RippleStateEntryReq `json:"ripple_state,omitempty"` + Check string `json:"check,omitempty"` + Escrow json.RawMessage `json:"escrow,omitempty"` + PaymentChannel string `json:"payment_channel,omitempty"` + DepositPreauth json.RawMessage `json:"deposit_preauth,omitempty"` + Ticket json.RawMessage `json:"ticket,omitempty"` } var h lerHelper err := json.Unmarshal(data, &h) @@ -115,6 +243,7 @@ func (r *LedgerEntryRequest) UnmarshalJSON(data []byte) error { AccountRoot: h.AccountRoot, Check: h.Check, PaymentChannel: h.PaymentChannel, + RippleState: h.RippleState, } r.LedgerIndex, err = common.UnmarshalLedgerSpecifier(h.LedgerIndex) if err != nil { @@ -128,10 +257,6 @@ func (r *LedgerEntryRequest) UnmarshalJSON(data []byte) error { if err != nil { return err } - r.RippleState, err = parseEntryRequestField(h.RippleState, &RippleStateEntryReq{}) - if err != nil { - return err - } r.Escrow, err = parseEntryRequestField(h.Escrow, &EscrowEntryReq{}) if err != nil { return err diff --git a/model/client/ledger/ledger_request.go b/model/client/ledger/ledger_request.go index 0f004783..bc16c3cf 100644 --- a/model/client/ledger/ledger_request.go +++ b/model/client/ledger/ledger_request.go @@ -23,6 +23,10 @@ func (*LedgerRequest) Method() string { return "ledger" } +func (*LedgerRequest) Validate() error { + return nil +} + func (r *LedgerRequest) UnmarshalJSON(data []byte) error { type lrHelper struct { LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"` From 1480b93abec697c095748e6fc96c840f2a277f66 Mon Sep 17 00:00:00 2001 From: PR Date: Thu, 7 Sep 2023 14:42:18 -0700 Subject: [PATCH 07/32] path/book validation --- model/client/path/book_offers_request.go | 16 ++++++++++ .../client/path/deposit_authorized_request.go | 12 ++++++++ .../client/path/nftoken_buy_offers_request.go | 8 +++++ .../path/nftoken_sell_offers_request.go | 8 +++++ model/client/path/path_find_request.go | 26 +++++++++++++++++ model/client/path/ripple_path_find_request.go | 29 +++++++++++++++++++ model/transactions/types/currency_amount.go | 26 +++++++++++++++++ 7 files changed, 125 insertions(+) diff --git a/model/client/path/book_offers_request.go b/model/client/path/book_offers_request.go index f33492f7..e873e1e4 100644 --- a/model/client/path/book_offers_request.go +++ b/model/client/path/book_offers_request.go @@ -2,6 +2,7 @@ package path import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -20,6 +21,21 @@ func (*BookOffersRequest) Method() string { return "book_offers" } +func (r *BookOffersRequest) Validate() error { + if err := r.TakerGets.Validate(); err != nil { + return fmt.Errorf("book offers taker gets: %w", err) + } + if err := r.TakerPays.Validate(); err != nil { + return fmt.Errorf("book offers taker pays: %w", err) + } + + if err := r.Taker.Validate(); r.Taker != "" && err != nil { + return fmt.Errorf("book offers taker: %w", err) + } + + return nil +} + func (r *BookOffersRequest) UnmarshalJSON(data []byte) error { type borHelper struct { TakerGets types.IssuedCurrencyAmount `json:"taker_gets"` diff --git a/model/client/path/deposit_authorized_request.go b/model/client/path/deposit_authorized_request.go index ccb15c9a..5e577f22 100644 --- a/model/client/path/deposit_authorized_request.go +++ b/model/client/path/deposit_authorized_request.go @@ -2,6 +2,7 @@ package path import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -18,6 +19,17 @@ func (*DepositAuthorizedRequest) Method() string { return "deposit_authorized" } +func (r *DepositAuthorizedRequest) Validate() error { + if err := r.SourceAccount.Validate(); err != nil { + return fmt.Errorf("deposit authorized source: %w", err) + } + if err := r.DestinationAccount.Validate(); err != nil { + return fmt.Errorf("deposit authorized destination: %w", err) + } + + return nil +} + func (r *DepositAuthorizedRequest) UnmarshalJSON(data []byte) error { type darHelper struct { SourceAccount types.Address `json:"source_account"` diff --git a/model/client/path/nftoken_buy_offers_request.go b/model/client/path/nftoken_buy_offers_request.go index caf65176..f31a7c5a 100644 --- a/model/client/path/nftoken_buy_offers_request.go +++ b/model/client/path/nftoken_buy_offers_request.go @@ -2,6 +2,7 @@ package path import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -19,6 +20,13 @@ func (*NFTokenBuyOffersRequest) Method() string { return "nft_buy_offers" } +func (r *NFTokenBuyOffersRequest) Validat() error { + if r.NFTokenID == "" { + return fmt.Errorf("nft buy offer missing token id") + } + return nil +} + func (r *NFTokenBuyOffersRequest) UnmarshalJSON(data []byte) error { type borHelper struct { NFTokenID types.NFTokenID `json:"nft_id"` diff --git a/model/client/path/nftoken_sell_offers_request.go b/model/client/path/nftoken_sell_offers_request.go index 38393581..5db10fb1 100644 --- a/model/client/path/nftoken_sell_offers_request.go +++ b/model/client/path/nftoken_sell_offers_request.go @@ -2,6 +2,7 @@ package path import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -19,6 +20,13 @@ func (*NFTokenSellOffersRequest) Method() string { return "nft_sell_offers" } +func (r *NFTokenSellOffersRequest) Validate() error { + if r.NFTokenID == "" { + return fmt.Errorf("nft sell offer missing token id") + } + return nil +} + func (r *NFTokenSellOffersRequest) UnmarshalJSON(data []byte) error { type borHelper struct { NFTokenID types.NFTokenID `json:"nft_id"` diff --git a/model/client/path/path_find_request.go b/model/client/path/path_find_request.go index 13545f9d..e4bb3cc1 100644 --- a/model/client/path/path_find_request.go +++ b/model/client/path/path_find_request.go @@ -2,6 +2,7 @@ package path import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/transactions" "github.com/xyield/xrpl-go/model/transactions/types" @@ -28,6 +29,31 @@ func (*PathFindRequest) Method() string { return "path_find" } +func (r *PathFindRequest) Validate() error { + switch r.Subcommand { + case CREATE: + if err := r.SourceAccount.Validate(); err != nil { + return fmt.Errorf("path find create source: %w", err) + } + if err := r.DestinationAccount.Validate(); err != nil { + return fmt.Errorf("path find create destination: %w", err) + } + if err := r.DestinationAmount.Validate(); err != nil { + return fmt.Errorf("path find create destination amount: %w", err) + } + if r.SendMax != nil { + if err := r.SendMax.Validate(); err != nil { + return fmt.Errorf("path find create send max: %w", err) + } + } + return nil + case CLOSE, STATUS: + return nil + default: + return fmt.Errorf("path find: invalid subcommand") + } +} + func (r *PathFindRequest) UnmarshalJSON(data []byte) error { type pfrHelper struct { Subcommand PathSubCommand `json:"subcommand"` diff --git a/model/client/path/ripple_path_find_request.go b/model/client/path/ripple_path_find_request.go index 58dd35e4..dec54012 100644 --- a/model/client/path/ripple_path_find_request.go +++ b/model/client/path/ripple_path_find_request.go @@ -2,6 +2,7 @@ package path import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -21,6 +22,34 @@ func (*RipplePathFindRequest) Method() string { return "ripple_path_find" } +func (r *RipplePathFindRequest) Validate() error { + if err := r.SourceAccount.Validate(); err != nil { + return fmt.Errorf("ripple path find source: %w", err) + } + if err := r.DestinationAccount.Validate(); err != nil { + return fmt.Errorf("ripple path find destination: %w", err) + } + if err := r.DestinationAmount.Validate(); err != nil { + return fmt.Errorf("ripple path find destination amount: %w", err) + } + if r.SendMax != nil && len(r.SourceCurrencies) != 0 { + return fmt.Errorf("ripple path find cannot have send max and source currencies set simultaneously") + } + if r.SendMax != nil { + if err := r.SendMax.Validate(); err != nil { + return fmt.Errorf("ripple path find send max: %w", err) + } + } + if len(r.SourceCurrencies) != 0 { + for _, c := range r.SourceCurrencies { + if err := c.Validate(); err != nil { + return fmt.Errorf("ripple path find source currencies: %w", err) + } + } + } + return nil +} + func (r *RipplePathFindRequest) UnmarshalJSON(data []byte) error { type rpfHelper struct { SourceAccount types.Address `json:"source_account"` diff --git a/model/transactions/types/currency_amount.go b/model/transactions/types/currency_amount.go index dd87f30d..050678f4 100644 --- a/model/transactions/types/currency_amount.go +++ b/model/transactions/types/currency_amount.go @@ -2,6 +2,7 @@ package types import ( "encoding/json" + "fmt" "strconv" ) @@ -14,6 +15,7 @@ const ( type CurrencyAmount interface { Kind() CurrencyKind + Validate() error } func UnmarshalCurrencyAmount(data []byte) (CurrencyAmount, error) { @@ -42,6 +44,26 @@ type IssuedCurrencyAmount struct { Value string `json:"value,omitempty"` } +func (i IssuedCurrencyAmount) Validate() error { + if i.Currency == "" { + return fmt.Errorf("issued currency: missing currency code") + } + if i.Currency == "XRP" && i.Issuer != "" { + return fmt.Errorf("issued currency: xrp cannot be issued") + + } + /* + // Issuer not required for source currencies field (path find request) + if i.Currency != "XRP" && i.Issuer == "" { + return fmt.Errorf("issued currency: non-xrp currencies require and issuer") + } + */ + if err := i.Issuer.Validate(); i.Issuer != "" && err != nil { + return fmt.Errorf("issued currency: %w", err) + } + return nil +} + func (IssuedCurrencyAmount) Kind() CurrencyKind { return ISSUED } @@ -52,6 +74,10 @@ func (XRPCurrencyAmount) Kind() CurrencyKind { return XRP } +func (XRPCurrencyAmount) Validate() error { + return nil +} + func (a XRPCurrencyAmount) MarshalJSON() ([]byte, error) { s := strconv.FormatUint(uint64(a), 10) return json.Marshal(s) From 435b6c8000c34b103ed5815448234bf706b3d14f Mon Sep 17 00:00:00 2001 From: PR Date: Mon, 11 Sep 2023 15:19:21 -0700 Subject: [PATCH 08/32] server request validation --- model/client/server/fee_request.go | 4 ++++ model/client/server/manifest_request.go | 4 ++++ model/client/server/server_info_request.go | 4 ++++ model/client/server/server_state_request.go | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/model/client/server/fee_request.go b/model/client/server/fee_request.go index a90db311..25a08e39 100644 --- a/model/client/server/fee_request.go +++ b/model/client/server/fee_request.go @@ -6,3 +6,7 @@ type FeeRequest struct { func (*FeeRequest) Method() string { return "fee" } + +func (*FeeRequest) Validate() error { + return nil +} diff --git a/model/client/server/manifest_request.go b/model/client/server/manifest_request.go index b48b0ca1..2aae6dca 100644 --- a/model/client/server/manifest_request.go +++ b/model/client/server/manifest_request.go @@ -7,3 +7,7 @@ type ManifestRequest struct { func (*ManifestRequest) Method() string { return "manifest" } + +func (*ManifestRequest) Validate() error { + return nil +} diff --git a/model/client/server/server_info_request.go b/model/client/server/server_info_request.go index 398bb383..fdb8c582 100644 --- a/model/client/server/server_info_request.go +++ b/model/client/server/server_info_request.go @@ -6,3 +6,7 @@ type ServerInfoRequest struct { func (*ServerInfoRequest) Method() string { return "server_info" } + +func (*ServerInfoRequest) Validate() error { + return nil +} diff --git a/model/client/server/server_state_request.go b/model/client/server/server_state_request.go index ed9f628b..8c9e646a 100644 --- a/model/client/server/server_state_request.go +++ b/model/client/server/server_state_request.go @@ -6,3 +6,7 @@ type ServerStateRequest struct { func (*ServerStateRequest) Method() string { return "server_state" } + +func (*ServerStateRequest) Validate() error { + return nil +} From 4e762f2ca7a8a3ebb2d357b7dde0da0aa0df8fb9 Mon Sep 17 00:00:00 2001 From: PR Date: Mon, 11 Sep 2023 15:37:39 -0700 Subject: [PATCH 09/32] subscribe validation --- .../client/subscription/subscribe_request.go | 22 ++++++++++++++++++- .../subscription/unsubscribe_request.go | 22 ++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/model/client/subscription/subscribe_request.go b/model/client/subscription/subscribe_request.go index 407723fa..5383ee07 100644 --- a/model/client/subscription/subscribe_request.go +++ b/model/client/subscription/subscribe_request.go @@ -1,6 +1,10 @@ package subscribe -import "github.com/xyield/xrpl-go/model/transactions/types" +import ( + "fmt" + + "github.com/xyield/xrpl-go/model/transactions/types" +) type SubscribeRequest struct { Streams []string `json:"streams,omitempty"` @@ -23,3 +27,19 @@ type SubscribeOrderBook struct { Snapshot bool `json:"snapshot,omitempty"` Both bool `json:"both,omitempty"` } + +func (r *SubscribeRequest) Validate() error { + for _, a := range r.Accounts { + if err := a.Validate(); err != nil { + return fmt.Errorf("subscribe request accounts: %w", err) + } + } + + for _, a := range r.AccountsProposed { + if err := a.Validate(); err != nil { + return fmt.Errorf("subscribe request accounts proposed: %w", err) + } + } + + return nil +} diff --git a/model/client/subscription/unsubscribe_request.go b/model/client/subscription/unsubscribe_request.go index 2339a9d8..ccb8a941 100644 --- a/model/client/subscription/unsubscribe_request.go +++ b/model/client/subscription/unsubscribe_request.go @@ -1,6 +1,10 @@ package subscribe -import "github.com/xyield/xrpl-go/model/transactions/types" +import ( + "fmt" + + "github.com/xyield/xrpl-go/model/transactions/types" +) type UnsubscribeRequest struct { Streams []string `json:"streams,omitempty"` @@ -18,3 +22,19 @@ type UnsubscribeOrderBook struct { TakerPays types.IssuedCurrencyAmount `json:"taker_pays"` Both bool `json:"both,omitempty"` } + +func (r *UnsubscribeRequest) Validate() error { + for _, a := range r.Accounts { + if err := a.Validate(); err != nil { + return fmt.Errorf("unsubscribe request accounts: %w", err) + } + } + + for _, a := range r.AccountsProposed { + if err := a.Validate(); err != nil { + return fmt.Errorf("unsubscribe request accounts proposed: %w", err) + } + } + + return nil +} From b7628898547bcd629f182604094f94f920017997 Mon Sep 17 00:00:00 2001 From: PR Date: Mon, 11 Sep 2023 15:45:13 -0700 Subject: [PATCH 10/32] transactions validation --- model/client/transactions/submit_multisigned_request.go | 4 ++++ model/client/transactions/submit_request.go | 4 ++++ model/client/transactions/transaction_entry_request.go | 4 ++++ model/client/transactions/tx_request.go | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/model/client/transactions/submit_multisigned_request.go b/model/client/transactions/submit_multisigned_request.go index 72259b68..e6d6d6dc 100644 --- a/model/client/transactions/submit_multisigned_request.go +++ b/model/client/transactions/submit_multisigned_request.go @@ -35,3 +35,7 @@ func (r *SubmitMultisignedRequest) UnmarshalJSON(data []byte) error { return nil } + +func (*SubmitMultisignedRequest) Validate() error { + return nil +} diff --git a/model/client/transactions/submit_request.go b/model/client/transactions/submit_request.go index b67ff4bc..45cea96f 100644 --- a/model/client/transactions/submit_request.go +++ b/model/client/transactions/submit_request.go @@ -8,3 +8,7 @@ type SubmitRequest struct { func (*SubmitRequest) Method() string { return "submit" } + +func (*SubmitRequest) Validate() error { + return nil +} diff --git a/model/client/transactions/transaction_entry_request.go b/model/client/transactions/transaction_entry_request.go index b56262e0..835aaa3b 100644 --- a/model/client/transactions/transaction_entry_request.go +++ b/model/client/transactions/transaction_entry_request.go @@ -38,3 +38,7 @@ func (t *TransactionEntryRequest) UnmarshalJSON(data []byte) error { t.LedgerIndex = i return nil } + +func (*TransactionEntryRequest) Validate() error { + return nil +} diff --git a/model/client/transactions/tx_request.go b/model/client/transactions/tx_request.go index 79103d15..70b2366a 100644 --- a/model/client/transactions/tx_request.go +++ b/model/client/transactions/tx_request.go @@ -12,3 +12,7 @@ type TxRequest struct { func (*TxRequest) Method() string { return "tx" } + +func (*TxRequest) Validate() error { + return nil +} From 5c5a7256c34e7c2e0d524e436150b5474cf5c27d Mon Sep 17 00:00:00 2001 From: PR Date: Mon, 11 Sep 2023 15:46:48 -0700 Subject: [PATCH 11/32] utility validation --- model/client/utility/random_request.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/model/client/utility/random_request.go b/model/client/utility/random_request.go index d0234240..9b85d6d2 100644 --- a/model/client/utility/random_request.go +++ b/model/client/utility/random_request.go @@ -5,3 +5,7 @@ type RandomRequest struct{} func (*RandomRequest) Method() string { return "random" } + +func (*RandomRequest) Validate() error { + return nil +} From 22d44cb7704384b404b4fd547b11aadb999869cf Mon Sep 17 00:00:00 2001 From: PR Date: Tue, 26 Sep 2023 16:19:25 -0700 Subject: [PATCH 12/32] addl tests --- model/client/account/account_channels_test.go | 2 +- .../client/account/account_currencies_test.go | 11 ++++ model/client/account/account_info_test.go | 11 ++++ model/client/account/account_lines_test.go | 17 ++++++ model/client/admin/status/print_request.go | 12 ++++ model/client/admin/status/print_response.go | 5 ++ .../client/channel/channel_authorize_test.go | 13 +++++ model/client/ledger/ledger_entry_request.go | 12 ++-- model/client/ledger/ledger_entry_test.go | 58 +++++++++++++++++++ model/transactions/types/address.go | 3 + 10 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 model/client/admin/status/print_request.go create mode 100644 model/client/admin/status/print_response.go diff --git a/model/client/account/account_channels_test.go b/model/client/account/account_channels_test.go index 7fd8b9d1..88ce2f4c 100644 --- a/model/client/account/account_channels_test.go +++ b/model/client/account/account_channels_test.go @@ -72,5 +72,5 @@ func TestValidate(t *testing.T) { err := s.Validate() - assert.EqualError(t, err, "no account ID specified") + assert.ErrorContains(t, err, "missing xrpl address") } diff --git a/model/client/account/account_currencies_test.go b/model/client/account/account_currencies_test.go index 5de5d787..51c63aaa 100644 --- a/model/client/account/account_currencies_test.go +++ b/model/client/account/account_currencies_test.go @@ -3,6 +3,7 @@ package account import ( "testing" + "github.com/stretchr/testify/assert" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/test" ) @@ -55,3 +56,13 @@ func TestAccountCurrenciesResponse(t *testing.T) { t.Error(err) } } + +func TestAccountCurrenciesValidation(t *testing.T) { + s := AccountCurrenciesRequest{ + Account: "", + } + err := s.Validate() + + assert.ErrorContains(t, err, "missing xrpl address") + +} diff --git a/model/client/account/account_info_test.go b/model/client/account/account_info_test.go index d209f8f0..af6c6722 100644 --- a/model/client/account/account_info_test.go +++ b/model/client/account/account_info_test.go @@ -3,6 +3,7 @@ package account import ( "testing" + "github.com/stretchr/testify/assert" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/ledger" "github.com/xyield/xrpl-go/model/transactions/types" @@ -110,3 +111,13 @@ func TestAccountInfoResponse(t *testing.T) { t.Error(err) } } + +func TestAccountInfoValidate(t *testing.T) { + s := AccountInfoRequest{ + Account: "", + } + + err := s.Validate() + + assert.ErrorContains(t, err, "missing xrpl address") +} diff --git a/model/client/account/account_lines_test.go b/model/client/account/account_lines_test.go index 19fafafa..8d98a1d8 100644 --- a/model/client/account/account_lines_test.go +++ b/model/client/account/account_lines_test.go @@ -3,6 +3,7 @@ package account import ( "testing" + "github.com/stretchr/testify/assert" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/test" ) @@ -74,3 +75,19 @@ func TestAccountLinesResponse(t *testing.T) { t.Error(err) } } + +func TestAccountLinesValidate(t *testing.T) { + s := AccountLinesRequest{ + Account: "", + } + + err := s.Validate() + + assert.ErrorContains(t, err, "missing xrpl address") + + s.Account = "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59" + s.Limit = 2 + err = s.Validate() + + assert.ErrorContains(t, err, "invalid limit") +} diff --git a/model/client/admin/status/print_request.go b/model/client/admin/status/print_request.go new file mode 100644 index 00000000..5d98269e --- /dev/null +++ b/model/client/admin/status/print_request.go @@ -0,0 +1,12 @@ +package status + +type PrintRequest struct { +} + +func (*PrintRequest) Method() string { + return "print" +} + +func (*PrintRequest) Validate() error { + return nil +} diff --git a/model/client/admin/status/print_response.go b/model/client/admin/status/print_response.go new file mode 100644 index 00000000..cb7d6d91 --- /dev/null +++ b/model/client/admin/status/print_response.go @@ -0,0 +1,5 @@ +package status + +type PrintResponse struct { + App map[string]any `json:"app"` +} diff --git a/model/client/channel/channel_authorize_test.go b/model/client/channel/channel_authorize_test.go index 53e89e9c..907bb8ab 100644 --- a/model/client/channel/channel_authorize_test.go +++ b/model/client/channel/channel_authorize_test.go @@ -3,6 +3,7 @@ package channel import ( "testing" + "github.com/stretchr/testify/assert" "github.com/xyield/xrpl-go/model/transactions/types" "github.com/xyield/xrpl-go/test" ) @@ -39,3 +40,15 @@ func TestChannelAuthorizeResponse(t *testing.T) { t.Error(err) } } + +func TestChannelAuthorizeValidate(t *testing.T) { + s := ChannelAuthorizeRequest{} + err := s.Validate() + assert.ErrorContains(t, err, "missing channel id") + + s = ChannelAuthorizeRequest{ + ChannelID: "abc", + } + err = s.Validate() + assert.Nil(t, err) +} diff --git a/model/client/ledger/ledger_entry_request.go b/model/client/ledger/ledger_entry_request.go index 24f69515..f85915e9 100644 --- a/model/client/ledger/ledger_entry_request.go +++ b/model/client/ledger/ledger_entry_request.go @@ -93,7 +93,7 @@ func (r *LedgerEntryRequest) Validate() error { } if setCount != 1 { - return fmt.Errorf("ledger entry: exactly one ledger entry object may be requested") + return fmt.Errorf("ledger entry: exactly one ledger entry object may be requested, found %d", setCount) } return nil @@ -133,7 +133,7 @@ func (*OfferEntryReq) LedgerEntryRequestField() {} func (r *OfferEntryReq) Validate() error { if err := r.Account.Validate(); err != nil { - return fmt.Errorf("offer entry: %w", err) + return fmt.Errorf("offer entry account: %w", err) } return nil } @@ -149,9 +149,9 @@ func (r *RippleStateEntryReq) Validate() error { if len(r.Accounts) != 2 { return fmt.Errorf("ripple state entry requires two accounts") } - for _, a := range r.Accounts { + for i, a := range r.Accounts { if err := a.Validate(); err != nil { - return fmt.Errorf("ripple state entry: %w", err) + return fmt.Errorf("ripple state entry account %d: %w", i+1, err) } } return nil @@ -166,7 +166,7 @@ func (*EscrowEntryReq) LedgerEntryRequestField() {} func (r *EscrowEntryReq) Validate() error { if err := r.Owner.Validate(); err != nil { - return fmt.Errorf("escrow entry: %w", err) + return fmt.Errorf("escrow entry owner: %w", err) } return nil } @@ -197,7 +197,7 @@ func (*TicketEntryReq) LedgerEntryRequestField() {} func (r *TicketEntryReq) Validate() error { if err := r.Account.Validate(); err != nil { - return fmt.Errorf("ticket entry: %w", err) + return fmt.Errorf("ticket entry account: %w", err) } return nil } diff --git a/model/client/ledger/ledger_entry_test.go b/model/client/ledger/ledger_entry_test.go index aaefa667..8f2ad31b 100644 --- a/model/client/ledger/ledger_entry_test.go +++ b/model/client/ledger/ledger_entry_test.go @@ -3,6 +3,7 @@ package ledger import ( "testing" + "github.com/stretchr/testify/assert" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/ledger" "github.com/xyield/xrpl-go/model/transactions/types" @@ -72,3 +73,60 @@ func TestLedgerEntryResponse(t *testing.T) { t.Error(err) } } + +func TestLedgerEntryValidate(t *testing.T) { + off := &OfferEntryReq{} + err := off.Validate() + assert.ErrorContains(t, err, "offer") + off.Account = "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn" + err = off.Validate() + assert.Nil(t, err) + + rs := RippleStateEntryReq{} + err = rs.Validate() + assert.ErrorContains(t, err, "requires two accounts") + rs.Accounts = []types.Address{"rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn", ""} + err = rs.Validate() + assert.ErrorContains(t, err, "account 2") + rs.Accounts[1] = "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCc" + err = rs.Validate() + assert.Nil(t, err) + + esc := EscrowEntryReq{} + err = esc.Validate() + assert.ErrorContains(t, err, "escrow entry owner") + esc.Owner = "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn" + err = esc.Validate() + assert.Nil(t, err) + + dep := DepositPreauthEntryReq{} + err = dep.Validate() + assert.ErrorContains(t, err, "deposit preauth") + dep.Owner = "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn" + err = dep.Validate() + assert.ErrorContains(t, err, "authorized") + dep.Authorized = "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCC" + err = dep.Validate() + assert.Nil(t, err) + + tick := TicketEntryReq{} + err = tick.Validate() + assert.ErrorContains(t, err, "ticket") + tick.Account = "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn" + err = tick.Validate() + assert.Nil(t, err) + + s := LedgerEntryRequest{} + err = s.Validate() + assert.ErrorContains(t, err, "0") + s.AccountRoot = "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn" + err = s.Validate() + assert.Nil(t, err) + s.Offer = off + err = s.Validate() + assert.ErrorContains(t, err, "2") + s.AccountRoot = "" + s.Offer = &OfferEntryReq{} + err = s.Validate() + assert.ErrorContains(t, err, "ledger entry offer") +} diff --git a/model/transactions/types/address.go b/model/transactions/types/address.go index f6f2ec8c..1e183804 100644 --- a/model/transactions/types/address.go +++ b/model/transactions/types/address.go @@ -9,6 +9,9 @@ type Address string func (a Address) Validate() error { characters := []string{"0", "O", "I", "l"} + if len(a) == 0 { + return fmt.Errorf("missing xrpl address") + } if len(a) < 25 || len(a) > 35 { return fmt.Errorf("invalid xrpl address length") } From d8364f00cf11a51e3e86336c0e7d4072d295e238 Mon Sep 17 00:00:00 2001 From: PR Date: Sat, 21 Oct 2023 12:43:02 -0700 Subject: [PATCH 13/32] typo --- model/client/admin/server/ledger_accept_request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/client/admin/server/ledger_accept_request.go b/model/client/admin/server/ledger_accept_request.go index 9804ddfe..3e47223b 100644 --- a/model/client/admin/server/ledger_accept_request.go +++ b/model/client/admin/server/ledger_accept_request.go @@ -4,7 +4,7 @@ type LedgerAcceptRequest struct { } func (*LedgerAcceptRequest) Method() string { - return "leder_accept" + return "ledger_accept" } func (*LedgerAcceptRequest) Validate() error { From 0565c169f7637910a477910fa65aa4b6a500160f Mon Sep 17 00:00:00 2001 From: PR Date: Sat, 21 Oct 2023 14:33:47 -0700 Subject: [PATCH 14/32] complete client impl --- client/accounts.go | 92 +++++++++++++++++- client/channels.go | 40 ++++++++ client/ledgers.go | 82 ++++++++++++++++ client/path.go | 94 +++++++++++++++++++ client/server.go | 66 +++++++++++++ client/subscriptions.go | 40 ++++++++ client/transactions.go | 68 ++++++++++++++ .../client/account/account_lines_response.go | 2 +- .../client/subscription/subscribe_request.go | 2 +- .../client/subscription/subscribe_response.go | 2 +- model/client/subscription/subscribe_test.go | 2 +- .../subscription/unsubscribe_request.go | 2 +- .../subscription/unsubscribe_response.go | 2 +- model/client/subscription/unsubscribe_test.go | 2 +- 14 files changed, 485 insertions(+), 11 deletions(-) create mode 100644 client/channels.go create mode 100644 client/ledgers.go create mode 100644 client/path.go create mode 100644 client/server.go create mode 100644 client/subscriptions.go create mode 100644 client/transactions.go diff --git a/client/accounts.go b/client/accounts.go index 438e8cc5..76154482 100644 --- a/client/accounts.go +++ b/client/accounts.go @@ -5,15 +5,21 @@ import ( ) type Account interface { - GetAccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, XRPLResponse, error) - GetAccountInfo(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error) + AccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, XRPLResponse, error) + AccountCurrencies(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error) + AccountInfo(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error) + AccountLines(req *account.AccountLinesRequest) (*account.AccountLinesResponse, XRPLResponse, error) + AccountNFTs(req *account.AccountNFTsRequest) (*account.AccountNFTsResponse, XRPLResponse, error) + AccountObjects(req *account.AccountObjectsRequest) (*account.AccountObjectsResponse, XRPLResponse, error) + AccountOffers(req *account.AccountOffersRequest) (*account.AccountOffersResponse, XRPLResponse, error) + AccountTransactions(req *account.AccountTransactionsRequest) (*account.AccountTransactionsResponse, XRPLResponse, error) } type accountImpl struct { client Client } -func (a *accountImpl) GetAccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, XRPLResponse, error) { +func (a *accountImpl) AccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, XRPLResponse, error) { res, err := a.client.SendRequest(req) if err != nil { return nil, nil, err @@ -26,7 +32,20 @@ func (a *accountImpl) GetAccountChannels(req *account.AccountChannelsRequest) (* return &acr, res, nil } -func (a *accountImpl) GetAccountInfo(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error) { +func (a *accountImpl) AccountCurrencies(req *account.AccountCurrenciesRequest) (*account.AccountCurrenciesResponse, XRPLResponse, error) { + res, err := a.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var acr account.AccountCurrenciesResponse + err = res.GetResult(&acr) + if err != nil { + return nil, nil, err + } + return &acr, res, nil +} + +func (a *accountImpl) AccountInfo(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error) { res, err := a.client.SendRequest(req) if err != nil { return nil, nil, err @@ -38,3 +57,68 @@ func (a *accountImpl) GetAccountInfo(req *account.AccountInfoRequest) (*account. } return &air, res, nil } + +func (a *accountImpl) AccountLines(req *account.AccountLinesRequest) (*account.AccountLinesResponse, XRPLResponse, error) { + res, err := a.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var alr account.AccountLinesResponse + err = res.GetResult(&alr) + if err != nil { + return nil, nil, err + } + return &alr, res, nil +} + +func (a *accountImpl) AccountNFTs(req *account.AccountNFTsRequest) (*account.AccountNFTsResponse, XRPLResponse, error) { + res, err := a.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var anr account.AccountNFTsResponse + err = res.GetResult(&anr) + if err != nil { + return nil, nil, err + } + return &anr, res, nil +} + +func (a *accountImpl) AccountObjects(req *account.AccountObjectsRequest) (*account.AccountObjectsResponse, XRPLResponse, error) { + res, err := a.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var aor account.AccountObjectsResponse + err = res.GetResult(&aor) + if err != nil { + return nil, nil, err + } + return &aor, res, nil +} + +func (a *accountImpl) AccountOffers(req *account.AccountOffersRequest) (*account.AccountOffersResponse, XRPLResponse, error) { + res, err := a.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var aor account.AccountOffersResponse + err = res.GetResult(&aor) + if err != nil { + return nil, nil, err + } + return &aor, res, nil +} + +func (a *accountImpl) AccountTransactions(req *account.AccountTransactionsRequest) (*account.AccountTransactionsResponse, XRPLResponse, error) { + res, err := a.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var atr account.AccountTransactionsResponse + err = res.GetResult(&atr) + if err != nil { + return nil, nil, err + } + return &atr, res, nil +} diff --git a/client/channels.go b/client/channels.go new file mode 100644 index 00000000..108e5ce6 --- /dev/null +++ b/client/channels.go @@ -0,0 +1,40 @@ +package client + +import ( + "github.com/xyield/xrpl-go/model/client/channel" +) + +type Channel interface { + ChannelAuthorize(req *channel.ChannelAuthorizeRequest) (*channel.ChannelAuthorizeRequest, XRPLResponse, error) + ChannelVerify(req *channel.ChannelVerifyRequest) (*channel.ChannelVerifyResponse, XRPLResponse, error) +} + +type channelImpl struct { + client Client +} + +func (c *channelImpl) ChannelAuthorize(req *channel.ChannelAuthorizeRequest) (*channel.ChannelAuthorizeResponse, XRPLResponse, error) { + res, err := c.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var car channel.ChannelAuthorizeResponse + err = res.GetResult(&car) + if err != nil { + return nil, nil, err + } + return &car, res, nil +} + +func (c *channelImpl) ChannelVerify(req *channel.ChannelVerifyRequest) (*channel.ChannelVerifyResponse, XRPLResponse, error) { + res, err := c.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var cvr channel.ChannelVerifyResponse + err = res.GetResult(&cvr) + if err != nil { + return nil, nil, err + } + return &cvr, res, nil +} diff --git a/client/ledgers.go b/client/ledgers.go new file mode 100644 index 00000000..16a26444 --- /dev/null +++ b/client/ledgers.go @@ -0,0 +1,82 @@ +package client + +import ( + "github.com/xyield/xrpl-go/model/client/ledger" +) + +type Ledger interface { + LedgerClosed(req *ledger.LedgerClosedRequest) (*ledger.LedgerClosedRequest, XRPLResponse, error) + LedgerCurrent(req *ledger.LedgerCurrentRequest) (*ledger.LedgerCurrentRequest, XRPLResponse, error) + LedgerData(req *ledger.LedgerDataRequest) (*ledger.LedgerDataRequest, XRPLResponse, error) + LedgerEntry(req *ledger.LedgerEntryRequest) (*ledger.LedgerEntryRequest, XRPLResponse, error) + Ledger(req *ledger.LedgerRequest) (*ledger.LedgerRequest, XRPLResponse, error) +} + +type ledgerImpl struct { + client Client +} + +func (l *ledgerImpl) LedgerClosed(req *ledger.LedgerClosedRequest) (*ledger.LedgerClosedResponse, XRPLResponse, error) { + res, err := l.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var lcr ledger.LedgerClosedResponse + err = res.GetResult(&lcr) + if err != nil { + return nil, nil, err + } + return &lcr, res, nil +} + +func (l *ledgerImpl) LedgerCurrent(req *ledger.LedgerCurrentRequest) (*ledger.LedgerCurrentResponse, XRPLResponse, error) { + res, err := l.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var lcr ledger.LedgerCurrentResponse + err = res.GetResult(&lcr) + if err != nil { + return nil, nil, err + } + return &lcr, res, nil +} + +func (l *ledgerImpl) LedgerData(req *ledger.LedgerDataRequest) (*ledger.LedgerDataResponse, XRPLResponse, error) { + res, err := l.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var ldr ledger.LedgerDataResponse + err = res.GetResult(&ldr) + if err != nil { + return nil, nil, err + } + return &ldr, res, nil +} + +func (l *ledgerImpl) LedgerEntry(req *ledger.LedgerEntryRequest) (*ledger.LedgerEntryResponse, XRPLResponse, error) { + res, err := l.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var ler ledger.LedgerEntryResponse + err = res.GetResult(&ler) + if err != nil { + return nil, nil, err + } + return &ler, res, nil +} + +func (l *ledgerImpl) Ledger(req *ledger.LedgerRequest) (*ledger.LedgerResponse, XRPLResponse, error) { + res, err := l.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var lr ledger.LedgerResponse + err = res.GetResult(&lr) + if err != nil { + return nil, nil, err + } + return &lr, res, nil +} diff --git a/client/path.go b/client/path.go new file mode 100644 index 00000000..fbb0e5cc --- /dev/null +++ b/client/path.go @@ -0,0 +1,94 @@ +package client + +import "github.com/xyield/xrpl-go/model/client/path" + +type PathBook interface { + BookOffers(req *path.BookOffersRequest) (*path.BookOffersResponse, XRPLResponse, error) + DepositAuthorized(req *path.DepositAuthorizedRequest) (*path.DepositAuthorizedResponse, XRPLResponse, error) + NFTokenBuyOffers(req *path.NFTokenBuyOffersRequest) (*path.NFTokenBuyOffersResponse, XRPLResponse, error) + NFTokenSellOffers(req *path.NFTokenSellOffersRequest) (*path.NFTokenSellOffersResponse, XRPLResponse, error) + PathFind(req *path.PathFindRequest) (*path.PathFindResponse, XRPLResponse, error) + RipplePathFind(req *path.RipplePathFindRequest) (*path.RipplePathFindResponse, XRPLResponse, error) +} + +type pathImpl struct { + client Client +} + +func (p *pathImpl) BookOffers(req *path.BookOffersRequest) (*path.BookOffersResponse, XRPLResponse, error) { + res, err := p.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var bor path.BookOffersResponse + err = res.GetResult(&bor) + if err != nil { + return nil, nil, err + } + return &bor, res, nil +} + +func (p *pathImpl) DepositAuthorized(req *path.DepositAuthorizedRequest) (*path.DepositAuthorizedResponse, XRPLResponse, error) { + res, err := p.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var dar path.DepositAuthorizedResponse + err = res.GetResult(&dar) + if err != nil { + return nil, nil, err + } + return &dar, res, nil +} + +func (p *pathImpl) NFTBuyOffers(req *path.NFTokenBuyOffersRequest) (*path.NFTokenBuyOffersResponse, XRPLResponse, error) { + res, err := p.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var nbr path.NFTokenBuyOffersResponse + err = res.GetResult(&nbr) + if err != nil { + return nil, nil, err + } + return &nbr, res, nil +} + +func (p *pathImpl) NFTokenSellOffers(req *path.NFTokenSellOffersRequest) (*path.NFTokenSellOffersResponse, XRPLResponse, error) { + res, err := p.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var nsr path.NFTokenSellOffersResponse + err = res.GetResult(&nsr) + if err != nil { + return nil, nil, err + } + return &nsr, res, nil +} + +func (p *pathImpl) PathFind(req *path.PathFindRequest) (*path.PathFindResponse, XRPLResponse, error) { + res, err := p.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var pfr path.PathFindResponse + err = res.GetResult(&pfr) + if err != nil { + return nil, nil, err + } + return &pfr, res, nil +} + +func (p *pathImpl) RipplePathFind(req *path.RipplePathFindRequest) (*path.RipplePathFindResponse, XRPLResponse, error) { + res, err := p.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var rpfr path.RipplePathFindResponse + err = res.GetResult(&rpfr) + if err != nil { + return nil, nil, err + } + return &rpfr, res, nil +} diff --git a/client/server.go b/client/server.go new file mode 100644 index 00000000..27bef12b --- /dev/null +++ b/client/server.go @@ -0,0 +1,66 @@ +package client + +import "github.com/xyield/xrpl-go/model/client/server" + +type Server interface { + Fee(*server.FeeRequest) (*server.FeeResponse, XRPLResponse, error) + Manifest(*server.ManifestRequest) (*server.ManifestResponse, XRPLResponse, error) + ServerInfo(*server.ServerInfoRequest) (*server.ServerInfoResponse, XRPLResponse, error) + ServerState(*server.ServerStateRequest) (*server.ServerStateRequest, XRPLResponse, error) +} + +type serverImpl struct { + client Client +} + +func (s *serverImpl) Fee(req *server.FeeRequest) (*server.FeeResponse, XRPLResponse, error) { + res, err := s.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var fr server.FeeResponse + err = res.GetResult(&fr) + if err != nil { + return nil, nil, err + } + return &fr, res, nil +} + +func (s *serverImpl) Manifest(req *server.ManifestRequest) (*server.ManifestResponse, XRPLResponse, error) { + res, err := s.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var mr server.ManifestResponse + err = res.GetResult(&mr) + if err != nil { + return nil, nil, err + } + return &mr, res, nil +} + +func (s *serverImpl) ServerInfo(req *server.ServerInfoRequest) (*server.ServerInfoResponse, XRPLResponse, error) { + res, err := s.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var sir server.ServerInfoResponse + err = res.GetResult(&sir) + if err != nil { + return nil, nil, err + } + return &sir, res, nil +} + +func (s *serverImpl) ServerState(req *server.ServerStateRequest) (*server.ServerStateResponse, XRPLResponse, error) { + res, err := s.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var ssr server.ServerStateResponse + err = res.GetResult(&ssr) + if err != nil { + return nil, nil, err + } + return &ssr, res, nil +} diff --git a/client/subscriptions.go b/client/subscriptions.go new file mode 100644 index 00000000..4e33eb82 --- /dev/null +++ b/client/subscriptions.go @@ -0,0 +1,40 @@ +package client + +import ( + "github.com/xyield/xrpl-go/model/client/subscription" +) + +type Subscription interface { + Subscribe(*subscription.SubscribeRequest) (*subscription.SubscribeResponse, XRPLResponse, error) + Unsubscribe(*subscription.UnsubscribeRequest) (*subscription.UnsubscribeResponse, XRPLResponse, error) +} + +type subscriptionImpl struct { + client Client +} + +func (s *subscriptionImpl) Subscribe(req *subscription.SubscribeRequest) (*subscription.SubscribeResponse, XRPLResponse, error) { + res, err := s.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var sr subscription.SubscribeResponse + err = res.GetResult(&sr) + if err != nil { + return nil, nil, err + } + return &sr, res, nil +} + +func (s *subscriptionImpl) Unsubscribe(req *subscription.UnsubscribeRequest) (*subscription.UnsubscribeResponse, XRPLResponse, error) { + res, err := s.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var ur subscription.UnsubscribeResponse + err = res.GetResult(&ur) + if err != nil { + return nil, nil, err + } + return &ur, res, nil +} diff --git a/client/transactions.go b/client/transactions.go new file mode 100644 index 00000000..8aaacf44 --- /dev/null +++ b/client/transactions.go @@ -0,0 +1,68 @@ +package client + +import ( + "github.com/xyield/xrpl-go/model/client/transactions" +) + +type Transaction interface { + SubmitMultisigned(*transactions.SubmitMultisignedRequest) (*transactions.SubmitMultisignedResponse, XRPLResponse, error) + Submit(*transactions.SubmitRequest) (*transactions.SubmitResponse, XRPLResponse, error) + TransactionEntry(*transactions.TransactionEntryRequest) (*transactions.TransactionEntryResponse, XRPLResponse, error) + Tx(*transactions.TxRequest) (*transactions.TxResponse, XRPLResponse, error) +} + +type transactionImpl struct { + client Client +} + +func (t *transactionImpl) SubmitMultisigned(req *transactions.SubmitMultisignedRequest) (*transactions.SubmitMultisignedResponse, XRPLResponse, error) { + res, err := t.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var smr transactions.SubmitMultisignedResponse + err = res.GetResult(&smr) + if err != nil { + return nil, nil, err + } + return &smr, res, nil +} + +func (t *transactionImpl) Submit(req *transactions.SubmitRequest) (*transactions.SubmitResponse, XRPLResponse, error) { + res, err := t.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var sr transactions.SubmitResponse + err = res.GetResult(&sr) + if err != nil { + return nil, nil, err + } + return &sr, res, nil +} + +func (t *transactionImpl) TransactionEntry(req *transactions.TransactionEntryRequest) (*transactions.TransactionEntryResponse, XRPLResponse, error) { + res, err := t.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var ter transactions.TransactionEntryResponse + err = res.GetResult(&ter) + if err != nil { + return nil, nil, err + } + return &ter, res, nil +} + +func (t *transactionImpl) Tx(req *transactions.TxRequest) (*transactions.TxResponse, XRPLResponse, error) { + res, err := t.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var tr transactions.TxResponse + err = res.GetResult(&tr) + if err != nil { + return nil, nil, err + } + return &tr, res, nil +} diff --git a/model/client/account/account_lines_response.go b/model/client/account/account_lines_response.go index d8c5c1a0..ed32acda 100644 --- a/model/client/account/account_lines_response.go +++ b/model/client/account/account_lines_response.go @@ -5,7 +5,7 @@ import ( "github.com/xyield/xrpl-go/model/transactions/types" ) -type AccountLinesReponse struct { +type AccountLinesResponse struct { Account types.Address `json:"account"` Lines []TrustLine `json:"lines"` LedgerCurrentIndex common.LedgerIndex `json:"ledger_current_index,omitempty"` diff --git a/model/client/subscription/subscribe_request.go b/model/client/subscription/subscribe_request.go index 407723fa..29b51dcb 100644 --- a/model/client/subscription/subscribe_request.go +++ b/model/client/subscription/subscribe_request.go @@ -1,4 +1,4 @@ -package subscribe +package subscription import "github.com/xyield/xrpl-go/model/transactions/types" diff --git a/model/client/subscription/subscribe_response.go b/model/client/subscription/subscribe_response.go index 43905fce..d4f28501 100644 --- a/model/client/subscription/subscribe_response.go +++ b/model/client/subscription/subscribe_response.go @@ -1,4 +1,4 @@ -package subscribe +package subscription import ( "github.com/xyield/xrpl-go/model/client/common" diff --git a/model/client/subscription/subscribe_test.go b/model/client/subscription/subscribe_test.go index 04944560..f4ce14fc 100644 --- a/model/client/subscription/subscribe_test.go +++ b/model/client/subscription/subscribe_test.go @@ -1,4 +1,4 @@ -package subscribe +package subscription import ( "testing" diff --git a/model/client/subscription/unsubscribe_request.go b/model/client/subscription/unsubscribe_request.go index 2339a9d8..1715bdb9 100644 --- a/model/client/subscription/unsubscribe_request.go +++ b/model/client/subscription/unsubscribe_request.go @@ -1,4 +1,4 @@ -package subscribe +package subscription import "github.com/xyield/xrpl-go/model/transactions/types" diff --git a/model/client/subscription/unsubscribe_response.go b/model/client/subscription/unsubscribe_response.go index e3583a4b..b52c0706 100644 --- a/model/client/subscription/unsubscribe_response.go +++ b/model/client/subscription/unsubscribe_response.go @@ -1,4 +1,4 @@ -package subscribe +package subscription type UnsubscribeResponse struct { } diff --git a/model/client/subscription/unsubscribe_test.go b/model/client/subscription/unsubscribe_test.go index b0576cdf..297e4633 100644 --- a/model/client/subscription/unsubscribe_test.go +++ b/model/client/subscription/unsubscribe_test.go @@ -1,4 +1,4 @@ -package subscribe +package subscription import ( "testing" From 7c9fd4f7dd8bb6512b8461f0d1daab808f1274fe Mon Sep 17 00:00:00 2001 From: PR Date: Thu, 18 Jan 2024 11:56:19 -0800 Subject: [PATCH 15/32] requested changes --- model/client/account/account_lines_request.go | 8 +++++++- .../admin/data/download_shard_request.go | 11 ++++++++-- .../admin/key/wallet_propose_request.go | 17 +++++++++++++++- model/client/admin/peer/connect_request.go | 7 ++++++- .../peer/peer_reservations_add_request.go | 7 ++++++- .../peer/peer_reservations_del_request.go | 7 ++++++- .../client/admin/signing/sign_for_request.go | 17 ++++++++++++++++ .../channel/channel_authorize_request.go | 20 ++++++++++++++++++- .../client/channel/channel_authorize_test.go | 10 ++++++++++ .../client/channel/channel_verify_request.go | 19 +++++++++++++++--- model/client/clio/nft_info_request.go | 6 +++++- model/client/ledger/ledger_entry_request.go | 7 ++++++- model/client/server/manifest_request.go | 7 ++++++- .../submit_multisigned_request.go | 6 +++++- model/client/transactions/submit_request.go | 7 ++++++- .../transactions/transaction_entry_request.go | 6 +++++- model/client/transactions/tx_request.go | 11 ++++++++-- model/transactions/types/hash256.go | 12 +++++++++++ model/transactions/types/nftoken_id.go | 10 ++++++++++ 19 files changed, 176 insertions(+), 19 deletions(-) diff --git a/model/client/account/account_lines_request.go b/model/client/account/account_lines_request.go index 825466f0..c5bbf6c3 100644 --- a/model/client/account/account_lines_request.go +++ b/model/client/account/account_lines_request.go @@ -23,13 +23,19 @@ func (*AccountLinesRequest) Method() string { func (r *AccountLinesRequest) Validate() error { if err := r.Account.Validate(); err != nil { - return fmt.Errorf("account lines request: %w", err) + return fmt.Errorf("account lines request account: %w", err) } if r.Limit != 0 && (r.Limit < 10 || r.Limit > 400) { return fmt.Errorf("account lines request: invalid limit, must be 10 <= limit <= 400") } + if r.Peer != "" { + if err := r.Peer.Validate(); err != nil { + return fmt.Errorf("account lines request peer: %w", err) + } + } + return nil } func (r *AccountLinesRequest) UnmarshalJSON(data []byte) error { diff --git a/model/client/admin/data/download_shard_request.go b/model/client/admin/data/download_shard_request.go index 4ad3d0db..b4cdfb3d 100644 --- a/model/client/admin/data/download_shard_request.go +++ b/model/client/admin/data/download_shard_request.go @@ -1,6 +1,10 @@ package data -import "github.com/xyield/xrpl-go/model/client/common" +import ( + "fmt" + + "github.com/xyield/xrpl-go/model/client/common" +) type DownloadShardRequest struct { Shards []ShardDescriptor `json:"shards"` @@ -15,6 +19,9 @@ func (*DownloadShardRequest) Method() string { return "download_shard" } -func (*DownloadShardRequest) Validate() error { +func (d *DownloadShardRequest) Validate() error { + if len(d.Shards) == 0 { + return fmt.Errorf("download shard request: no shard descriptors provided") + } return nil } diff --git a/model/client/admin/key/wallet_propose_request.go b/model/client/admin/key/wallet_propose_request.go index e61e6fa7..27f36e0e 100644 --- a/model/client/admin/key/wallet_propose_request.go +++ b/model/client/admin/key/wallet_propose_request.go @@ -1,5 +1,7 @@ package key +import "fmt" + type WalletProposeRequest struct { KeyType string `json:"key_type,omitempty"` Passphrase string `json:"passphrase,omitempty"` @@ -11,6 +13,19 @@ func (*WalletProposeRequest) Method() string { return "wallet_propose" } -func (*WalletProposeRequest) Validate() error { +func (p *WalletProposeRequest) Validate() error { + cnt := 0 + if p.Passphrase != "" { + cnt++ + } + if p.Seed != "" { + cnt++ + } + if p.SeedHex != "" { + cnt++ + } + if cnt > 1 { + return fmt.Errorf("wallet propose request: only one of (passphrase, seed, seedhex) may be set") + } return nil } diff --git a/model/client/admin/peer/connect_request.go b/model/client/admin/peer/connect_request.go index c8acf829..177eaf42 100644 --- a/model/client/admin/peer/connect_request.go +++ b/model/client/admin/peer/connect_request.go @@ -1,5 +1,7 @@ package peer +import "fmt" + type ConnectRequest struct { IP string `json:"ip"` Port int `json:"port,omitempty"` @@ -9,6 +11,9 @@ func (*ConnectRequest) Method() string { return "connect" } -func (*ConnectRequest) Validate() error { +func (c *ConnectRequest) Validate() error { + if c.IP == "" { + return fmt.Errorf("connect request: missing ip") + } return nil } diff --git a/model/client/admin/peer/peer_reservations_add_request.go b/model/client/admin/peer/peer_reservations_add_request.go index e763ec87..a8da95fd 100644 --- a/model/client/admin/peer/peer_reservations_add_request.go +++ b/model/client/admin/peer/peer_reservations_add_request.go @@ -1,5 +1,7 @@ package peer +import "fmt" + type PeerReservationAddRequest struct { PublicKey string `json:"public_key"` Description string `json:"description,omitempty"` @@ -9,6 +11,9 @@ func (*PeerReservationAddRequest) Method() string { return "peer_reservations_add" } -func (*PeerReservationAddRequest) Validate() error { +func (r *PeerReservationAddRequest) Validate() error { + if r.PublicKey == "" { + return fmt.Errorf("peer reservation add request: missing publickey") + } return nil } diff --git a/model/client/admin/peer/peer_reservations_del_request.go b/model/client/admin/peer/peer_reservations_del_request.go index f2262fbc..34e9f49e 100644 --- a/model/client/admin/peer/peer_reservations_del_request.go +++ b/model/client/admin/peer/peer_reservations_del_request.go @@ -1,5 +1,7 @@ package peer +import "fmt" + type PeerReservationDelRequest struct { PublicKey string `json:"public_key"` } @@ -8,6 +10,9 @@ func (*PeerReservationDelRequest) Method() string { return "peer_reservations_del" } -func (*PeerReservationDelRequest) Validate() error { +func (r *PeerReservationDelRequest) Validate() error { + if r.PublicKey == "" { + return fmt.Errorf("peer reservation del request: missing publickey") + } return nil } diff --git a/model/client/admin/signing/sign_for_request.go b/model/client/admin/signing/sign_for_request.go index b4f56219..523641e4 100644 --- a/model/client/admin/signing/sign_for_request.go +++ b/model/client/admin/signing/sign_for_request.go @@ -31,6 +31,23 @@ func (r *SignForRequest) Validate() error { return fmt.Errorf("sign for request: empty tx") } + cnt := 0 + if r.Secret != "" { + cnt++ + } + if r.Seed != "" { + cnt++ + } + if r.SeedHex != "" { + cnt++ + } + if r.Passphrase != "" { + cnt++ + } + if cnt != 1 { + return fmt.Errorf("sign for request: must provide one of (secret, seed, seedhex, passphrase)") + } + return nil } diff --git a/model/client/channel/channel_authorize_request.go b/model/client/channel/channel_authorize_request.go index 26513d26..9ec03f41 100644 --- a/model/client/channel/channel_authorize_request.go +++ b/model/client/channel/channel_authorize_request.go @@ -24,7 +24,25 @@ func (r *ChannelAuthorizeRequest) Validate() error { if r.ChannelID == "" { return fmt.Errorf("channel authorize request: missing channel id") } - + var set []string + if r.Secret != "" { + set = append(set, "secret") + } + if r.Seed != "" { + set = append(set, "seed") + } + if r.SeedHex != "" { + set = append(set, "seed_hex") + } + if r.Passphrase != "" { + set = append(set, "passphrase") + } + if len(set) == 0 { + return fmt.Errorf("channel authorize request: at least one of (secret, seed, seed_hex, passphrase) must be set") + } + if len(set) > 1 { + return fmt.Errorf("channel authorize request: only one signing method required, currently set %v", set) + } return nil } diff --git a/model/client/channel/channel_authorize_test.go b/model/client/channel/channel_authorize_test.go index 907bb8ab..13d09dc2 100644 --- a/model/client/channel/channel_authorize_test.go +++ b/model/client/channel/channel_authorize_test.go @@ -50,5 +50,15 @@ func TestChannelAuthorizeValidate(t *testing.T) { ChannelID: "abc", } err = s.Validate() + assert.ErrorContains(t, err, "seed") + s = ChannelAuthorizeRequest{ + ChannelID: "abc", + Seed: "123", + } + err = s.Validate() assert.Nil(t, err) + s.Secret = "def" + err = s.Validate() + assert.ErrorContains(t, err, "seed") + assert.ErrorContains(t, err, "secret") } diff --git a/model/client/channel/channel_verify_request.go b/model/client/channel/channel_verify_request.go index 4a4b18a8..f3bede1b 100644 --- a/model/client/channel/channel_verify_request.go +++ b/model/client/channel/channel_verify_request.go @@ -1,10 +1,14 @@ package channel -import "github.com/xyield/xrpl-go/model/transactions/types" +import ( + "fmt" + + "github.com/xyield/xrpl-go/model/transactions/types" +) type ChannelVerifyRequest struct { Amount types.XRPCurrencyAmount `json:"amount"` - ChannelID string `json:"channel_id"` + ChannelID types.Hash256 `json:"channel_id"` PublicKey string `json:"public_key"` Signature string `json:"signature"` } @@ -13,6 +17,15 @@ func (*ChannelVerifyRequest) Method() string { return "channel_verify" } -func (*ChannelVerifyRequest) Validate() error { +func (r *ChannelVerifyRequest) Validate() error { + if err := r.ChannelID.Validate(); err != nil { + return fmt.Errorf("channel verify request: channel id: %w", err) + } + if r.PublicKey == "" { + return fmt.Errorf("channel verify request: public key not set") + } + if r.Signature == "" { + return fmt.Errorf("channel verify request: signature not set") + } return nil } diff --git a/model/client/clio/nft_info_request.go b/model/client/clio/nft_info_request.go index c12f2369..962327e7 100644 --- a/model/client/clio/nft_info_request.go +++ b/model/client/clio/nft_info_request.go @@ -2,6 +2,7 @@ package clio import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" "github.com/xyield/xrpl-go/model/transactions/types" @@ -17,7 +18,10 @@ func (*NFTInfoRequest) Method() string { return "nft_info" } -func (*NFTInfoRequest) Validate() error { +func (r *NFTInfoRequest) Validate() error { + if err := r.NFTokenID.Validate(); err != nil { + return fmt.Errorf("nft info request: %w", err) + } return nil } diff --git a/model/client/ledger/ledger_entry_request.go b/model/client/ledger/ledger_entry_request.go index f85915e9..d7f1ab05 100644 --- a/model/client/ledger/ledger_entry_request.go +++ b/model/client/ledger/ledger_entry_request.go @@ -22,6 +22,7 @@ type LedgerEntryRequest struct { PaymentChannel string `json:"payment_channel,omitempty"` DepositPreauth EntryRequestOrString `json:"deposit_preauth,omitempty"` Ticket EntryRequestOrString `json:"ticket,omitempty"` + NFTPage string `json:"nft_page,omitempty"` } func (*LedgerEntryRequest) Method() string { @@ -58,7 +59,7 @@ func (r *LedgerEntryRequest) Validate() error { if r.RippleState != nil { setCount++ - if err := r.Offer.Validate(); err != nil { + if err := r.RippleState.Validate(); err != nil { return fmt.Errorf("ledger entry ripple state: %w", err) } } @@ -92,6 +93,10 @@ func (r *LedgerEntryRequest) Validate() error { } } + if r.NFTPage != "" { + setCount++ + } + if setCount != 1 { return fmt.Errorf("ledger entry: exactly one ledger entry object may be requested, found %d", setCount) } diff --git a/model/client/server/manifest_request.go b/model/client/server/manifest_request.go index 2aae6dca..a2da5ad5 100644 --- a/model/client/server/manifest_request.go +++ b/model/client/server/manifest_request.go @@ -1,5 +1,7 @@ package server +import "fmt" + type ManifestRequest struct { PublicKey string `json:"public_key"` } @@ -8,6 +10,9 @@ func (*ManifestRequest) Method() string { return "manifest" } -func (*ManifestRequest) Validate() error { +func (r *ManifestRequest) Validate() error { + if r.PublicKey == "" { + return fmt.Errorf("manifest request: public key not set") + } return nil } diff --git a/model/client/transactions/submit_multisigned_request.go b/model/client/transactions/submit_multisigned_request.go index e6d6d6dc..ca4a9ee2 100644 --- a/model/client/transactions/submit_multisigned_request.go +++ b/model/client/transactions/submit_multisigned_request.go @@ -2,6 +2,7 @@ package transactions import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/transactions" ) @@ -36,6 +37,9 @@ func (r *SubmitMultisignedRequest) UnmarshalJSON(data []byte) error { return nil } -func (*SubmitMultisignedRequest) Validate() error { +func (s *SubmitMultisignedRequest) Validate() error { + if s.Tx == nil { + return fmt.Errorf("submit multisigned request: missing tx") + } return nil } diff --git a/model/client/transactions/submit_request.go b/model/client/transactions/submit_request.go index 45cea96f..c3fc30fd 100644 --- a/model/client/transactions/submit_request.go +++ b/model/client/transactions/submit_request.go @@ -1,5 +1,7 @@ package transactions +import "fmt" + type SubmitRequest struct { TxBlob string `json:"tx_blob"` FailHard bool `json:"fail_hard,omitempty"` @@ -9,6 +11,9 @@ func (*SubmitRequest) Method() string { return "submit" } -func (*SubmitRequest) Validate() error { +func (s *SubmitRequest) Validate() error { + if s.TxBlob == "" { + return fmt.Errorf("submit request: missing txblob") + } return nil } diff --git a/model/client/transactions/transaction_entry_request.go b/model/client/transactions/transaction_entry_request.go index 835aaa3b..5ebf9cd6 100644 --- a/model/client/transactions/transaction_entry_request.go +++ b/model/client/transactions/transaction_entry_request.go @@ -2,6 +2,7 @@ package transactions import ( "encoding/json" + "fmt" "github.com/xyield/xrpl-go/model/client/common" ) @@ -39,6 +40,9 @@ func (t *TransactionEntryRequest) UnmarshalJSON(data []byte) error { return nil } -func (*TransactionEntryRequest) Validate() error { +func (t *TransactionEntryRequest) Validate() error { + if t.TxHash == "" { + return fmt.Errorf("transaction entry request: missing txhash") + } return nil } diff --git a/model/client/transactions/tx_request.go b/model/client/transactions/tx_request.go index 70b2366a..ebc5ffce 100644 --- a/model/client/transactions/tx_request.go +++ b/model/client/transactions/tx_request.go @@ -1,6 +1,10 @@ package transactions -import "github.com/xyield/xrpl-go/model/client/common" +import ( + "fmt" + + "github.com/xyield/xrpl-go/model/client/common" +) type TxRequest struct { Transaction string `json:"transaction"` @@ -13,6 +17,9 @@ func (*TxRequest) Method() string { return "tx" } -func (*TxRequest) Validate() error { +func (t *TxRequest) Validate() error { + if t.Transaction == "" { + return fmt.Errorf("transaction request: missing transaction") + } return nil } diff --git a/model/transactions/types/hash256.go b/model/transactions/types/hash256.go index df068aa3..e63df929 100644 --- a/model/transactions/types/hash256.go +++ b/model/transactions/types/hash256.go @@ -1,3 +1,15 @@ package types +import "fmt" + type Hash256 string + +func (h Hash256) Validate() error { + if h == "" { + return fmt.Errorf("hash256 value not set") + } + if len(h) != 64 { + return fmt.Errorf("hash256 length was not expected 64 characters") + } + return nil +} diff --git a/model/transactions/types/nftoken_id.go b/model/transactions/types/nftoken_id.go index 438a0a42..c682b473 100644 --- a/model/transactions/types/nftoken_id.go +++ b/model/transactions/types/nftoken_id.go @@ -1,3 +1,13 @@ package types +import "fmt" + type NFTokenID Hash256 + +func (id NFTokenID) Validate() error { + h := Hash256(id) + if err := h.Validate(); err != nil { + return fmt.Errorf("nftoken id: %w", err) + } + return nil +} From 95e2980aa8707cb881adc33492214f631d831135 Mon Sep 17 00:00:00 2001 From: PR Date: Tue, 30 Jan 2024 13:26:31 -0800 Subject: [PATCH 16/32] bugfixes --- client/accounts.go | 2 +- client/accounts_test.go | 2 +- examples/jsonrpc-client/jsonrpc_client_example.go | 2 +- examples/websocket/main.go | 2 +- model/client/account/account_lines_test.go | 2 +- model/client/ledger/ledger_data_request.go | 4 ++++ model/client/path/nftoken_buy_offers_request.go | 2 +- 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/accounts.go b/client/accounts.go index 76154482..5ed8e049 100644 --- a/client/accounts.go +++ b/client/accounts.go @@ -6,7 +6,7 @@ import ( type Account interface { AccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, XRPLResponse, error) - AccountCurrencies(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error) + AccountCurrencies(req *account.AccountCurrenciesRequest) (*account.AccountCurrenciesResponse, XRPLResponse, error) AccountInfo(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error) AccountLines(req *account.AccountLinesRequest) (*account.AccountLinesResponse, XRPLResponse, error) AccountNFTs(req *account.AccountNFTsRequest) (*account.AccountNFTsResponse, XRPLResponse, error) diff --git a/client/accounts_test.go b/client/accounts_test.go index 9e18638b..9dabf128 100644 --- a/client/accounts_test.go +++ b/client/accounts_test.go @@ -118,7 +118,7 @@ func TestGetAccountChannels(t *testing.T) { cl.On("SendRequest", &tc.input).Return(&tc.sendRequestResult, nil) - res, _, err := a.GetAccountChannels(&tc.input) + res, _, err := a.AccountChannels(&tc.input) if tc.expectedErr != nil { require.EqualError(t, err, tc.expectedErr.Error()) diff --git a/examples/jsonrpc-client/jsonrpc_client_example.go b/examples/jsonrpc-client/jsonrpc_client_example.go index ac52bb96..5886bd13 100644 --- a/examples/jsonrpc-client/jsonrpc_client_example.go +++ b/examples/jsonrpc-client/jsonrpc_client_example.go @@ -22,7 +22,7 @@ func main() { // call the desired method var req *account.AccountChannelsRequest - ac, xrplRes, err := client.Account.GetAccountChannels(req) + ac, xrplRes, err := client.Account.AccountChannels(req) if err != nil { fmt.Println(err.Error()) } diff --git a/examples/websocket/main.go b/examples/websocket/main.go index 2fa577ed..4fa2f28b 100644 --- a/examples/websocket/main.go +++ b/examples/websocket/main.go @@ -10,7 +10,7 @@ import ( func main() { client := websocket.NewClient(&websocket.WebsocketConfig{URL: "wss://s.altnet.rippletest.net"}) - acr, _, err := client.Account.GetAccountInfo(&account.AccountInfoRequest{Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"}) + acr, _, err := client.Account.AccountInfo(&account.AccountInfoRequest{Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"}) if err != nil { panic(err) } diff --git a/model/client/account/account_lines_test.go b/model/client/account/account_lines_test.go index 8d98a1d8..a14a6b32 100644 --- a/model/client/account/account_lines_test.go +++ b/model/client/account/account_lines_test.go @@ -35,7 +35,7 @@ func TestAccountLinesRequest(t *testing.T) { } func TestAccountLinesResponse(t *testing.T) { - s := AccountLinesReponse{ + s := AccountLinesResponse{ Account: "rLHmBn4fT92w4F6ViyYbjoizLTo83tHTHu", Lines: []TrustLine{ { diff --git a/model/client/ledger/ledger_data_request.go b/model/client/ledger/ledger_data_request.go index dfa6f591..5420c48e 100644 --- a/model/client/ledger/ledger_data_request.go +++ b/model/client/ledger/ledger_data_request.go @@ -49,3 +49,7 @@ func (r *LedgerDataRequest) Validate() error { // invalid limits are overwritten server-side return nil } + +func (r *LedgerDataRequest) Method() string { + return "ledger_data" +} diff --git a/model/client/path/nftoken_buy_offers_request.go b/model/client/path/nftoken_buy_offers_request.go index f31a7c5a..1c3e96c9 100644 --- a/model/client/path/nftoken_buy_offers_request.go +++ b/model/client/path/nftoken_buy_offers_request.go @@ -20,7 +20,7 @@ func (*NFTokenBuyOffersRequest) Method() string { return "nft_buy_offers" } -func (r *NFTokenBuyOffersRequest) Validat() error { +func (r *NFTokenBuyOffersRequest) Validate() error { if r.NFTokenID == "" { return fmt.Errorf("nft buy offer missing token id") } From 6a64aa566b3a5698d5f650241c0ecfbb5d7abca3 Mon Sep 17 00:00:00 2001 From: PR Date: Tue, 30 Jan 2024 14:37:13 -0800 Subject: [PATCH 17/32] change imports --- binary-codec/main.go | 6 +++--- binary-codec/main_test.go | 2 +- binary-codec/serdes/binary_parser.go | 2 +- binary-codec/serdes/binary_serializer.go | 2 +- binary-codec/serdes/field_id_codec.go | 2 +- binary-codec/serdes/field_id_codec_test.go | 2 +- binary-codec/types/account_id.go | 4 ++-- binary-codec/types/amount.go | 6 +++--- binary-codec/types/amount_test.go | 2 +- binary-codec/types/blob.go | 2 +- binary-codec/types/hash.go | 2 +- binary-codec/types/pathset.go | 4 ++-- binary-codec/types/pathset_test.go | 2 +- binary-codec/types/serialized_type.go | 2 +- binary-codec/types/st_array.go | 2 +- binary-codec/types/st_object.go | 4 ++-- binary-codec/types/st_object_test.go | 2 +- binary-codec/types/uint16.go | 4 ++-- binary-codec/types/uint32.go | 2 +- binary-codec/types/uint64.go | 2 +- binary-codec/types/uint8.go | 4 ++-- binary-codec/types/vector256.go | 2 +- client/accounts.go | 2 +- client/accounts_test.go | 4 ++-- client/channels.go | 2 +- client/jsonrpc/jsonrpc_client.go | 4 ++-- client/jsonrpc/jsonrpc_client_test.go | 10 +++++----- client/jsonrpc/models/jsonrpc_response.go | 2 +- client/jsonrpc/models/jsonrpc_response_test.go | 4 ++-- client/ledgers.go | 2 +- client/path.go | 2 +- client/server.go | 2 +- client/subscriptions.go | 2 +- client/transactions.go | 2 +- client/websocket/utils.go | 2 +- client/websocket/utils_test.go | 4 ++-- client/websocket/websocket_client.go | 2 +- client/websocket/websocket_client_response.go | 2 +- client/websocket/websocket_client_test.go | 6 +++--- examples/jsonrpc-client/jsonrpc_client_example.go | 6 +++--- examples/websocket/main.go | 4 ++-- go.mod | 2 +- keypairs/ed25519.go | 2 +- keypairs/ed25519_test.go | 2 +- keypairs/keypairs.go | 2 +- keypairs/keypairs_test.go | 2 +- model/client/account/account_channels_request.go | 4 ++-- model/client/account/account_channels_response.go | 4 ++-- model/client/account/account_channels_test.go | 4 ++-- model/client/account/account_currencies_request.go | 4 ++-- model/client/account/account_currencies_response.go | 2 +- model/client/account/account_currencies_test.go | 4 ++-- model/client/account/account_info_request.go | 4 ++-- model/client/account/account_info_response.go | 4 ++-- model/client/account/account_info_test.go | 8 ++++---- model/client/account/account_lines_request.go | 4 ++-- model/client/account/account_lines_response.go | 4 ++-- model/client/account/account_lines_test.go | 4 ++-- model/client/account/account_nfts_request.go | 4 ++-- model/client/account/account_nfts_response.go | 4 ++-- model/client/account/account_nfts_test.go | 4 ++-- model/client/account/account_objects_request.go | 4 ++-- model/client/account/account_objects_response.go | 6 +++--- model/client/account/account_objects_test.go | 8 ++++---- model/client/account/account_offers_request.go | 4 ++-- model/client/account/account_offers_response.go | 4 ++-- model/client/account/account_offers_test.go | 6 +++--- model/client/account/account_transaction.go | 2 +- model/client/account/account_transactions_request.go | 4 ++-- model/client/account/account_transactions_response.go | 4 ++-- model/client/account/account_transactions_test.go | 10 +++++----- model/client/account/channel_result.go | 2 +- model/client/account/nft.go | 2 +- model/client/account/offer_result.go | 2 +- model/client/account/queue_data.go | 2 +- model/client/account/queue_transaction.go | 2 +- model/client/account/trust_line.go | 2 +- model/client/admin/data/can_delete_request.go | 2 +- model/client/admin/data/can_delete_test.go | 4 ++-- model/client/admin/data/crawl_shards_test.go | 2 +- model/client/admin/data/download_shard_request.go | 2 +- model/client/admin/data/download_shard_test.go | 2 +- model/client/admin/data/ledger_cleaner_request.go | 2 +- model/client/admin/data/ledger_cleaner_test.go | 2 +- model/client/admin/data/ledger_request_request.go | 2 +- model/client/admin/data/ledger_request_response.go | 4 ++-- model/client/admin/data/ledger_request_test.go | 6 +++--- model/client/admin/key/validation_create_test.go | 2 +- model/client/admin/key/wallet_propose_response.go | 2 +- model/client/admin/key/wallet_propose_test.go | 2 +- model/client/admin/peer/peer_reservations_list_test.go | 2 +- model/client/admin/peer/peers_test.go | 2 +- model/client/admin/server/ledger_accept_response.go | 2 +- model/client/admin/signing/sign_for_request.go | 4 ++-- model/client/admin/signing/sign_for_response.go | 2 +- model/client/admin/signing/sign_for_test.go | 6 +++--- model/client/admin/signing/sign_request.go | 2 +- model/client/admin/signing/sign_response.go | 2 +- model/client/admin/signing/sign_test.go | 6 +++--- model/client/admin/status/consensus_info_response.go | 2 +- model/client/admin/status/consensus_info_test.go | 2 +- model/client/admin/status/feature_test.go | 2 +- model/client/admin/status/fetch_info_test.go | 2 +- model/client/admin/status/get_counts_test.go | 2 +- model/client/admin/status/validator_info_test.go | 2 +- model/client/admin/status/validator_list_sites_test.go | 2 +- model/client/admin/status/validators_test.go | 2 +- model/client/channel/channel_authorize_request.go | 2 +- model/client/channel/channel_authorize_test.go | 4 ++-- model/client/channel/channel_verify_request.go | 2 +- model/client/channel/channel_verify_test.go | 4 ++-- model/client/clio/ledger_request.go | 2 +- model/client/clio/ledger_response.go | 8 ++++---- model/client/clio/ledger_test.go | 4 ++-- model/client/clio/nft_info_request.go | 4 ++-- model/client/clio/nft_info_response.go | 4 ++-- model/client/clio/nft_info_test.go | 4 ++-- model/client/clio/server_info_response.go | 2 +- model/client/clio/server_info_test.go | 2 +- model/client/ledger/ledger_closed_response.go | 2 +- model/client/ledger/ledger_closed_test.go | 2 +- model/client/ledger/ledger_current_response.go | 2 +- model/client/ledger/ledger_current_test.go | 2 +- model/client/ledger/ledger_data_request.go | 4 ++-- model/client/ledger/ledger_data_response.go | 4 ++-- model/client/ledger/ledger_data_test.go | 8 ++++---- model/client/ledger/ledger_entry_request.go | 4 ++-- model/client/ledger/ledger_entry_response.go | 4 ++-- model/client/ledger/ledger_entry_test.go | 8 ++++---- model/client/ledger/ledger_request.go | 4 ++-- model/client/ledger/ledger_response.go | 8 ++++---- model/client/ledger/ledger_test.go | 6 +++--- model/client/path/book_offers_request.go | 4 ++-- model/client/path/book_offers_response.go | 6 +++--- model/client/path/book_offers_test.go | 6 +++--- model/client/path/deposit_authorized_request.go | 4 ++-- model/client/path/deposit_authorized_response.go | 4 ++-- model/client/path/deposit_authorized_test.go | 4 ++-- model/client/path/nftoken_buy_offers_request.go | 4 ++-- model/client/path/nftoken_buy_offers_response.go | 2 +- model/client/path/nftoken_buy_offers_test.go | 6 +++--- model/client/path/nftoken_offer.go | 2 +- model/client/path/nftoken_sell_offers_request.go | 4 ++-- model/client/path/nftoken_sell_offers_response.go | 2 +- model/client/path/nftoken_sell_offers_test.go | 6 +++--- model/client/path/path_find_request.go | 4 ++-- model/client/path/path_find_response.go | 4 ++-- model/client/path/path_find_test.go | 6 +++--- model/client/path/ripple_path_find_request.go | 4 ++-- model/client/path/ripple_path_find_response.go | 2 +- model/client/path/ripple_path_find_test.go | 6 +++--- model/client/server/fee_response.go | 4 ++-- model/client/server/fee_test.go | 2 +- model/client/server/manifest_test.go | 2 +- model/client/server/server_info_response.go | 2 +- model/client/server/server_info_test.go | 2 +- model/client/server/server_state_test.go | 2 +- model/client/subscription/stream/ledger.go | 2 +- model/client/subscription/stream/peer.go | 2 +- model/client/subscription/stream/transaction.go | 4 ++-- model/client/subscription/stream/validation.go | 2 +- model/client/subscription/subscribe_request.go | 2 +- model/client/subscription/subscribe_response.go | 4 ++-- model/client/subscription/subscribe_test.go | 4 ++-- model/client/subscription/unsubscribe_request.go | 2 +- model/client/subscription/unsubscribe_test.go | 4 ++-- .../client/transactions/submit_multisigned_request.go | 2 +- .../client/transactions/submit_multisigned_response.go | 2 +- model/client/transactions/submit_multisigned_test.go | 6 +++--- model/client/transactions/submit_response.go | 4 ++-- model/client/transactions/submit_test.go | 6 +++--- model/client/transactions/transaction_entry_request.go | 2 +- .../client/transactions/transaction_entry_response.go | 4 ++-- model/client/transactions/transaction_entry_test.go | 10 +++++----- model/client/transactions/tx_request.go | 2 +- model/client/transactions/tx_response.go | 6 +++--- model/client/transactions/tx_test.go | 6 +++--- model/client/utility/random_response.go | 2 +- model/client/utility/random_test.go | 2 +- model/ledger/account_root.go | 2 +- model/ledger/account_root_test.go | 4 ++-- model/ledger/amendments.go | 2 +- model/ledger/amendments_test.go | 4 ++-- model/ledger/amm.go | 2 +- model/ledger/check.go | 2 +- model/ledger/check_test.go | 2 +- model/ledger/deposit_preauth.go | 2 +- model/ledger/deposit_preauth_test.go | 2 +- model/ledger/directory_node.go | 2 +- model/ledger/directory_node_test.go | 4 ++-- model/ledger/escrow.go | 2 +- model/ledger/escrow_test.go | 4 ++-- model/ledger/fee_settings_test.go | 2 +- model/ledger/ledger_hashes.go | 2 +- model/ledger/ledger_hashes_test.go | 4 ++-- model/ledger/negative_unl_test.go | 2 +- model/ledger/nftoken_offer.go | 2 +- model/ledger/nftoken_offer_test.go | 4 ++-- model/ledger/nftoken_page.go | 2 +- model/ledger/nftoken_page_test.go | 4 ++-- model/ledger/offer.go | 2 +- model/ledger/offer_test.go | 4 ++-- model/ledger/pay_channel.go | 2 +- model/ledger/pay_channel_test.go | 4 ++-- model/ledger/ripple_state.go | 2 +- model/ledger/ripple_state_test.go | 4 ++-- model/ledger/signer_list.go | 2 +- model/ledger/signer_list_test.go | 2 +- model/ledger/ticket.go | 2 +- model/ledger/ticket_test.go | 2 +- model/transactions/account_delete.go | 2 +- model/transactions/account_delete_test.go | 4 ++-- model/transactions/account_set.go | 2 +- model/transactions/account_set_test.go | 4 ++-- model/transactions/check_cancel.go | 2 +- model/transactions/check_cancel_test.go | 4 ++-- model/transactions/check_cash.go | 2 +- model/transactions/check_cash_test.go | 4 ++-- model/transactions/check_create.go | 2 +- model/transactions/check_create_test.go | 4 ++-- model/transactions/deposit_preauth.go | 2 +- model/transactions/deposit_preauth_test.go | 4 ++-- model/transactions/escrow_cancel.go | 2 +- model/transactions/escrow_cancel_test.go | 4 ++-- model/transactions/escrow_create.go | 2 +- model/transactions/escrow_create_test.go | 4 ++-- model/transactions/escrow_finish.go | 2 +- model/transactions/escrow_finish_test.go | 4 ++-- model/transactions/nftoken_accept_offer.go | 2 +- model/transactions/nftoken_accept_offer_test.go | 4 ++-- model/transactions/nftoken_burn.go | 2 +- model/transactions/nftoken_burn_test.go | 4 ++-- model/transactions/nftoken_cancel_offer.go | 2 +- model/transactions/nftoken_cancel_offer_test.go | 4 ++-- model/transactions/nftoken_create_offer.go | 2 +- model/transactions/nftoken_create_offer_test.go | 4 ++-- model/transactions/nftoken_mint.go | 2 +- model/transactions/nftoken_mint_test.go | 4 ++-- model/transactions/offer_cancel_test.go | 4 ++-- model/transactions/offer_create.go | 2 +- model/transactions/offer_create_test.go | 4 ++-- model/transactions/path_step.go | 2 +- model/transactions/payment.go | 2 +- model/transactions/payment_channel_claim.go | 2 +- model/transactions/payment_channel_claim_test.go | 4 ++-- model/transactions/payment_channel_create.go | 2 +- model/transactions/payment_channel_create_test.go | 4 ++-- model/transactions/payment_channel_fund.go | 2 +- model/transactions/payment_channel_fund_test.go | 4 ++-- model/transactions/payment_test.go | 4 ++-- model/transactions/set_regular_key.go | 2 +- model/transactions/set_regular_key_test.go | 4 ++-- model/transactions/signer.go | 2 +- model/transactions/signer_list_set.go | 2 +- model/transactions/signer_list_set_test.go | 6 +++--- model/transactions/ticket_create_test.go | 4 ++-- model/transactions/transaction_metadata.go | 4 ++-- model/transactions/trust_set.go | 2 +- model/transactions/trust_set_test.go | 4 ++-- model/transactions/tx.go | 2 +- 260 files changed, 424 insertions(+), 424 deletions(-) diff --git a/binary-codec/main.go b/binary-codec/main.go index e4a4997b..fd085ea6 100644 --- a/binary-codec/main.go +++ b/binary-codec/main.go @@ -6,10 +6,10 @@ import ( "errors" "strings" - "github.com/xyield/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" - "github.com/xyield/xrpl-go/binary-codec/serdes" - "github.com/xyield/xrpl-go/binary-codec/types" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/types" ) var ErrSigningClaimFieldNotFound = errors.New("'Channel' & 'Amount' fields are both required, but were not found") diff --git a/binary-codec/main_test.go b/binary-codec/main_test.go index 75aa1d22..d580c643 100644 --- a/binary-codec/main_test.go +++ b/binary-codec/main_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/binary-codec/types" + "github.com/CreatureDev/xrpl-go/binary-codec/types" ) func TestEncode(t *testing.T) { diff --git a/binary-codec/serdes/binary_parser.go b/binary-codec/serdes/binary_parser.go index 397ca664..e4edfa0c 100644 --- a/binary-codec/serdes/binary_parser.go +++ b/binary-codec/serdes/binary_parser.go @@ -3,7 +3,7 @@ package serdes import ( "errors" - "github.com/xyield/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" ) var ( diff --git a/binary-codec/serdes/binary_serializer.go b/binary-codec/serdes/binary_serializer.go index 5d3a8fdc..9fbf55da 100644 --- a/binary-codec/serdes/binary_serializer.go +++ b/binary-codec/serdes/binary_serializer.go @@ -3,7 +3,7 @@ package serdes import ( "errors" - "github.com/xyield/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" ) var ErrLengthPrefixTooLong = errors.New("length of value must not exceed 918744 bytes of data") diff --git a/binary-codec/serdes/field_id_codec.go b/binary-codec/serdes/field_id_codec.go index 4ef34aec..77ffda9f 100644 --- a/binary-codec/serdes/field_id_codec.go +++ b/binary-codec/serdes/field_id_codec.go @@ -3,7 +3,7 @@ package serdes import ( "encoding/hex" - "github.com/xyield/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" ) // Returns the unique field ID for a given field name. diff --git a/binary-codec/serdes/field_id_codec_test.go b/binary-codec/serdes/field_id_codec_test.go index 41d8e880..91ea1a8e 100644 --- a/binary-codec/serdes/field_id_codec_test.go +++ b/binary-codec/serdes/field_id_codec_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" ) func TestEncodeFieldID(t *testing.T) { diff --git a/binary-codec/types/account_id.go b/binary-codec/types/account_id.go index 3232e998..09314432 100644 --- a/binary-codec/types/account_id.go +++ b/binary-codec/types/account_id.go @@ -1,8 +1,8 @@ package types import ( - addresscodec "github.com/xyield/xrpl-go/address-codec" - "github.com/xyield/xrpl-go/binary-codec/serdes" + addresscodec "github.com/CreatureDev/xrpl-go/address-codec" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) // AccountID struct represents an account ID. diff --git a/binary-codec/types/amount.go b/binary-codec/types/amount.go index 57d648b0..d40bef67 100644 --- a/binary-codec/types/amount.go +++ b/binary-codec/types/amount.go @@ -11,9 +11,9 @@ import ( "strconv" "strings" - addresscodec "github.com/xyield/xrpl-go/address-codec" - "github.com/xyield/xrpl-go/binary-codec/serdes" - bigdecimal "github.com/xyield/xrpl-go/pkg/big-decimal" + addresscodec "github.com/CreatureDev/xrpl-go/address-codec" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + bigdecimal "github.com/CreatureDev/xrpl-go/pkg/big-decimal" ) const ( diff --git a/binary-codec/types/amount_test.go b/binary-codec/types/amount_test.go index 2f9d2478..9ff16544 100644 --- a/binary-codec/types/amount_test.go +++ b/binary-codec/types/amount_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - bigdecimal "github.com/xyield/xrpl-go/pkg/big-decimal" + bigdecimal "github.com/CreatureDev/xrpl-go/pkg/big-decimal" ) func TestVerifyXrpValue(t *testing.T) { diff --git a/binary-codec/types/blob.go b/binary-codec/types/blob.go index 4acdc808..8bf38f43 100644 --- a/binary-codec/types/blob.go +++ b/binary-codec/types/blob.go @@ -5,7 +5,7 @@ import ( "errors" "strings" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) // ErrNoLengthPrefix error is raised when no length prefix size is given. diff --git a/binary-codec/types/hash.go b/binary-codec/types/hash.go index fa5f2aef..ee298a8f 100644 --- a/binary-codec/types/hash.go +++ b/binary-codec/types/hash.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) // ErrInvalidHashLength struct is used when the hash length does not meet the expected value. diff --git a/binary-codec/types/pathset.go b/binary-codec/types/pathset.go index d35f90ec..06a9fafc 100644 --- a/binary-codec/types/pathset.go +++ b/binary-codec/types/pathset.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" - addresscodec "github.com/xyield/xrpl-go/address-codec" - "github.com/xyield/xrpl-go/binary-codec/serdes" + addresscodec "github.com/CreatureDev/xrpl-go/address-codec" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) const ( diff --git a/binary-codec/types/pathset_test.go b/binary-codec/types/pathset_test.go index ab00c418..9d54f8b1 100644 --- a/binary-codec/types/pathset_test.go +++ b/binary-codec/types/pathset_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) func TestIsPathStep(t *testing.T) { diff --git a/binary-codec/types/serialized_type.go b/binary-codec/types/serialized_type.go index 8d57572f..bdc6393b 100644 --- a/binary-codec/types/serialized_type.go +++ b/binary-codec/types/serialized_type.go @@ -1,6 +1,6 @@ package types -import "github.com/xyield/xrpl-go/binary-codec/serdes" +import "github.com/CreatureDev/xrpl-go/binary-codec/serdes" // SerializedType is an interface representing any type that can be serialized // and deserialized to and from JSON. diff --git a/binary-codec/types/st_array.go b/binary-codec/types/st_array.go index 48688cc8..d752bc8e 100644 --- a/binary-codec/types/st_array.go +++ b/binary-codec/types/st_array.go @@ -3,7 +3,7 @@ package types import ( "errors" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) const ( diff --git a/binary-codec/types/st_object.go b/binary-codec/types/st_object.go index 27dda6ea..cd668f36 100644 --- a/binary-codec/types/st_object.go +++ b/binary-codec/types/st_object.go @@ -4,8 +4,8 @@ import ( "fmt" "sort" - "github.com/xyield/xrpl-go/binary-codec/definitions" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) // STObject represents a map of serialized field instances, where each key is a field name diff --git a/binary-codec/types/st_object_test.go b/binary-codec/types/st_object_test.go index b6c98b83..ee9fc8c7 100644 --- a/binary-codec/types/st_object_test.go +++ b/binary-codec/types/st_object_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" ) func TestCreateFieldInstanceMapFromJson(t *testing.T) { diff --git a/binary-codec/types/uint16.go b/binary-codec/types/uint16.go index e0ea88c3..9ae76f92 100644 --- a/binary-codec/types/uint16.go +++ b/binary-codec/types/uint16.go @@ -4,8 +4,8 @@ import ( "bytes" "encoding/binary" - "github.com/xyield/xrpl-go/binary-codec/definitions" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) // UInt16 represents a 16-bit unsigned integer. diff --git a/binary-codec/types/uint32.go b/binary-codec/types/uint32.go index 28b6431e..f9a776aa 100644 --- a/binary-codec/types/uint32.go +++ b/binary-codec/types/uint32.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/binary" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) // UInt32 represents a 32-bit unsigned integer. diff --git a/binary-codec/types/uint64.go b/binary-codec/types/uint64.go index 67f78b6b..9de5a278 100644 --- a/binary-codec/types/uint64.go +++ b/binary-codec/types/uint64.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) // UInt64 represents a 64-bit unsigned integer. diff --git a/binary-codec/types/uint8.go b/binary-codec/types/uint8.go index 3c69c663..aeaa071e 100644 --- a/binary-codec/types/uint8.go +++ b/binary-codec/types/uint8.go @@ -4,8 +4,8 @@ import ( "bytes" "encoding/binary" - "github.com/xyield/xrpl-go/binary-codec/definitions" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) // UInt8 represents an 8-bit unsigned integer. diff --git a/binary-codec/types/vector256.go b/binary-codec/types/vector256.go index 4dd41caf..17f0926f 100644 --- a/binary-codec/types/vector256.go +++ b/binary-codec/types/vector256.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) const HashLengthBytes = 32 diff --git a/client/accounts.go b/client/accounts.go index 5ed8e049..d0199789 100644 --- a/client/accounts.go +++ b/client/accounts.go @@ -1,7 +1,7 @@ package client import ( - "github.com/xyield/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/model/client/account" ) type Account interface { diff --git a/client/accounts_test.go b/client/accounts_test.go index 9dabf128..5fb0aa2e 100644 --- a/client/accounts_test.go +++ b/client/accounts_test.go @@ -7,8 +7,8 @@ import ( "github.com/mitchellh/mapstructure" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/model/client/account" - "github.com/xyield/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/model/client/common" ) type mockClient struct { diff --git a/client/channels.go b/client/channels.go index 108e5ce6..751ede57 100644 --- a/client/channels.go +++ b/client/channels.go @@ -1,7 +1,7 @@ package client import ( - "github.com/xyield/xrpl-go/model/client/channel" + "github.com/CreatureDev/xrpl-go/model/client/channel" ) type Channel interface { diff --git a/client/jsonrpc/jsonrpc_client.go b/client/jsonrpc/jsonrpc_client.go index 769c1701..e1bae9ab 100644 --- a/client/jsonrpc/jsonrpc_client.go +++ b/client/jsonrpc/jsonrpc_client.go @@ -12,8 +12,8 @@ import ( "time" jsoniter "github.com/json-iterator/go" - "github.com/xyield/xrpl-go/client" - jsonrpcmodels "github.com/xyield/xrpl-go/client/jsonrpc/models" + "github.com/CreatureDev/xrpl-go/client" + jsonrpcmodels "github.com/CreatureDev/xrpl-go/client/jsonrpc/models" ) type JsonRpcClient struct { diff --git a/client/jsonrpc/jsonrpc_client_test.go b/client/jsonrpc/jsonrpc_client_test.go index d153a9c6..7df83fd3 100644 --- a/client/jsonrpc/jsonrpc_client_test.go +++ b/client/jsonrpc/jsonrpc_client_test.go @@ -11,11 +11,11 @@ import ( jsoniter "github.com/json-iterator/go" "github.com/stretchr/testify/assert" - "github.com/xyield/xrpl-go/client" - jsonrpcmodels "github.com/xyield/xrpl-go/client/jsonrpc/models" - "github.com/xyield/xrpl-go/model/client/account" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/client/utility" + "github.com/CreatureDev/xrpl-go/client" + jsonrpcmodels "github.com/CreatureDev/xrpl-go/client/jsonrpc/models" + "github.com/CreatureDev/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/utility" ) func TestJsonRpcClientCreation(t *testing.T) { diff --git a/client/jsonrpc/models/jsonrpc_response.go b/client/jsonrpc/models/jsonrpc_response.go index 03c3377a..79b3577e 100644 --- a/client/jsonrpc/models/jsonrpc_response.go +++ b/client/jsonrpc/models/jsonrpc_response.go @@ -2,7 +2,7 @@ package jsonrpcmodels import ( "github.com/mitchellh/mapstructure" - "github.com/xyield/xrpl-go/client" + "github.com/CreatureDev/xrpl-go/client" ) type JsonRpcResponse struct { diff --git a/client/jsonrpc/models/jsonrpc_response_test.go b/client/jsonrpc/models/jsonrpc_response_test.go index de9dbbd5..5f6cb8fd 100644 --- a/client/jsonrpc/models/jsonrpc_response_test.go +++ b/client/jsonrpc/models/jsonrpc_response_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/xyield/xrpl-go/client" - "github.com/xyield/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/client" + "github.com/CreatureDev/xrpl-go/model/client/account" ) func TestGetResult(t *testing.T) { diff --git a/client/ledgers.go b/client/ledgers.go index 16a26444..bd63db5d 100644 --- a/client/ledgers.go +++ b/client/ledgers.go @@ -1,7 +1,7 @@ package client import ( - "github.com/xyield/xrpl-go/model/client/ledger" + "github.com/CreatureDev/xrpl-go/model/client/ledger" ) type Ledger interface { diff --git a/client/path.go b/client/path.go index fbb0e5cc..0a895239 100644 --- a/client/path.go +++ b/client/path.go @@ -1,6 +1,6 @@ package client -import "github.com/xyield/xrpl-go/model/client/path" +import "github.com/CreatureDev/xrpl-go/model/client/path" type PathBook interface { BookOffers(req *path.BookOffersRequest) (*path.BookOffersResponse, XRPLResponse, error) diff --git a/client/server.go b/client/server.go index 27bef12b..a8817991 100644 --- a/client/server.go +++ b/client/server.go @@ -1,6 +1,6 @@ package client -import "github.com/xyield/xrpl-go/model/client/server" +import "github.com/CreatureDev/xrpl-go/model/client/server" type Server interface { Fee(*server.FeeRequest) (*server.FeeResponse, XRPLResponse, error) diff --git a/client/subscriptions.go b/client/subscriptions.go index 4e33eb82..87e95b0e 100644 --- a/client/subscriptions.go +++ b/client/subscriptions.go @@ -1,7 +1,7 @@ package client import ( - "github.com/xyield/xrpl-go/model/client/subscription" + "github.com/CreatureDev/xrpl-go/model/client/subscription" ) type Subscription interface { diff --git a/client/transactions.go b/client/transactions.go index 8aaacf44..964e535a 100644 --- a/client/transactions.go +++ b/client/transactions.go @@ -1,7 +1,7 @@ package client import ( - "github.com/xyield/xrpl-go/model/client/transactions" + "github.com/CreatureDev/xrpl-go/model/client/transactions" ) type Transaction interface { diff --git a/client/websocket/utils.go b/client/websocket/utils.go index d33daeef..ddba7cf9 100644 --- a/client/websocket/utils.go +++ b/client/websocket/utils.go @@ -4,7 +4,7 @@ import ( "encoding/json" "github.com/mitchellh/mapstructure" - "github.com/xyield/xrpl-go/client" + "github.com/CreatureDev/xrpl-go/client" ) func (c *WebsocketClient) formatRequest(req client.XRPLRequest, id int, marker any) ([]byte, error) { diff --git a/client/websocket/utils_test.go b/client/websocket/utils_test.go index aa89f5d7..a6e85064 100644 --- a/client/websocket/utils_test.go +++ b/client/websocket/utils_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/client" - "github.com/xyield/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/client" + "github.com/CreatureDev/xrpl-go/model/client/account" ) func TestFormatRequest(t *testing.T) { diff --git a/client/websocket/websocket_client.go b/client/websocket/websocket_client.go index ae25e448..1214aea5 100644 --- a/client/websocket/websocket_client.go +++ b/client/websocket/websocket_client.go @@ -7,7 +7,7 @@ import ( "sync/atomic" "github.com/gorilla/websocket" - "github.com/xyield/xrpl-go/client" + "github.com/CreatureDev/xrpl-go/client" ) var _ client.Client = (*WebsocketClient)(nil) diff --git a/client/websocket/websocket_client_response.go b/client/websocket/websocket_client_response.go index 696bb45a..93e9fa93 100644 --- a/client/websocket/websocket_client_response.go +++ b/client/websocket/websocket_client_response.go @@ -2,7 +2,7 @@ package websocket import ( "github.com/mitchellh/mapstructure" - "github.com/xyield/xrpl-go/client" + "github.com/CreatureDev/xrpl-go/client" ) var _ client.XRPLResponse = (*WebSocketClientXrplResponse)(nil) diff --git a/client/websocket/websocket_client_test.go b/client/websocket/websocket_client_test.go index 69332175..3d123232 100644 --- a/client/websocket/websocket_client_test.go +++ b/client/websocket/websocket_client_test.go @@ -6,9 +6,9 @@ import ( "github.com/gorilla/websocket" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/client" - "github.com/xyield/xrpl-go/model/client/account" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/client" + "github.com/CreatureDev/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/test" ) func TestSendRequest(t *testing.T) { diff --git a/examples/jsonrpc-client/jsonrpc_client_example.go b/examples/jsonrpc-client/jsonrpc_client_example.go index 5886bd13..44d11150 100644 --- a/examples/jsonrpc-client/jsonrpc_client_example.go +++ b/examples/jsonrpc-client/jsonrpc_client_example.go @@ -4,9 +4,9 @@ import ( "fmt" "log" - "github.com/xyield/xrpl-go/client" - jsonrpcclient "github.com/xyield/xrpl-go/client/jsonrpc" - "github.com/xyield/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/client" + jsonrpcclient "github.com/CreatureDev/xrpl-go/client/jsonrpc" + "github.com/CreatureDev/xrpl-go/model/client/account" ) func main() { diff --git a/examples/websocket/main.go b/examples/websocket/main.go index 4fa2f28b..39bcb1de 100644 --- a/examples/websocket/main.go +++ b/examples/websocket/main.go @@ -3,8 +3,8 @@ package main import ( "fmt" - "github.com/xyield/xrpl-go/client/websocket" - "github.com/xyield/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/client/websocket" + "github.com/CreatureDev/xrpl-go/model/client/account" ) func main() { diff --git a/go.mod b/go.mod index 1f3c50f3..77680b75 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/xyield/xrpl-go +module github.com/CreatureDev/xrpl-go go 1.19 diff --git a/keypairs/ed25519.go b/keypairs/ed25519.go index 8f46abe0..43945949 100644 --- a/keypairs/ed25519.go +++ b/keypairs/ed25519.go @@ -5,7 +5,7 @@ import ( "crypto/ed25519" "encoding/hex" - addresscodec "github.com/xyield/xrpl-go/address-codec" + addresscodec "github.com/CreatureDev/xrpl-go/address-codec" ) type ed25519Alg struct{} diff --git a/keypairs/ed25519_test.go b/keypairs/ed25519_test.go index 6f4154c2..4b50b9db 100644 --- a/keypairs/ed25519_test.go +++ b/keypairs/ed25519_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - addresscodec "github.com/xyield/xrpl-go/address-codec" + addresscodec "github.com/CreatureDev/xrpl-go/address-codec" ) func TestED25519DeriveKeypair(t *testing.T) { diff --git a/keypairs/keypairs.go b/keypairs/keypairs.go index 281676e4..9dc2e845 100644 --- a/keypairs/keypairs.go +++ b/keypairs/keypairs.go @@ -4,7 +4,7 @@ import ( "crypto/rand" "fmt" - addresscodec "github.com/xyield/xrpl-go/address-codec" + addresscodec "github.com/CreatureDev/xrpl-go/address-codec" ) var r randomizer diff --git a/keypairs/keypairs_test.go b/keypairs/keypairs_test.go index 4d927cd7..95cee780 100644 --- a/keypairs/keypairs_test.go +++ b/keypairs/keypairs_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - addresscodec "github.com/xyield/xrpl-go/address-codec" + addresscodec "github.com/CreatureDev/xrpl-go/address-codec" ) func TestGenerateEncodeSeed(t *testing.T) { diff --git a/model/client/account/account_channels_request.go b/model/client/account/account_channels_request.go index 14eb5e58..da6d2f1e 100644 --- a/model/client/account/account_channels_request.go +++ b/model/client/account/account_channels_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountChannelsRequest struct { diff --git a/model/client/account/account_channels_response.go b/model/client/account/account_channels_response.go index 7b865938..7d74f6cd 100644 --- a/model/client/account/account_channels_response.go +++ b/model/client/account/account_channels_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountChannelsResponse struct { diff --git a/model/client/account/account_channels_test.go b/model/client/account/account_channels_test.go index 88ce2f4c..8452f018 100644 --- a/model/client/account/account_channels_test.go +++ b/model/client/account/account_channels_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountChannelRequest(t *testing.T) { diff --git a/model/client/account/account_currencies_request.go b/model/client/account/account_currencies_request.go index a4d71205..524d2cdd 100644 --- a/model/client/account/account_currencies_request.go +++ b/model/client/account/account_currencies_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountCurrenciesRequest struct { diff --git a/model/client/account/account_currencies_response.go b/model/client/account/account_currencies_response.go index 4dc1fb49..99d3af2d 100644 --- a/model/client/account/account_currencies_response.go +++ b/model/client/account/account_currencies_response.go @@ -1,7 +1,7 @@ package account import ( - "github.com/xyield/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/common" ) type AccountCurrenciesResponse struct { diff --git a/model/client/account/account_currencies_test.go b/model/client/account/account_currencies_test.go index 51c63aaa..783e4a9b 100644 --- a/model/client/account/account_currencies_test.go +++ b/model/client/account/account_currencies_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountCurrenciesRequest(t *testing.T) { diff --git a/model/client/account/account_info_request.go b/model/client/account/account_info_request.go index 3c5cc4dd..dd951936 100644 --- a/model/client/account/account_info_request.go +++ b/model/client/account/account_info_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountInfoRequest struct { diff --git a/model/client/account/account_info_response.go b/model/client/account/account_info_response.go index 358e5f0c..75d32852 100644 --- a/model/client/account/account_info_response.go +++ b/model/client/account/account_info_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" ) type AccountInfoResponse struct { diff --git a/model/client/account/account_info_test.go b/model/client/account/account_info_test.go index af6c6722..ef4d9a8a 100644 --- a/model/client/account/account_info_test.go +++ b/model/client/account/account_info_test.go @@ -4,10 +4,10 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountInfoRequest(t *testing.T) { diff --git a/model/client/account/account_lines_request.go b/model/client/account/account_lines_request.go index c5bbf6c3..a6897cd9 100644 --- a/model/client/account/account_lines_request.go +++ b/model/client/account/account_lines_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountLinesRequest struct { diff --git a/model/client/account/account_lines_response.go b/model/client/account/account_lines_response.go index ed32acda..850fcefb 100644 --- a/model/client/account/account_lines_response.go +++ b/model/client/account/account_lines_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountLinesResponse struct { diff --git a/model/client/account/account_lines_test.go b/model/client/account/account_lines_test.go index a14a6b32..1f30ad4c 100644 --- a/model/client/account/account_lines_test.go +++ b/model/client/account/account_lines_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountLinesRequest(t *testing.T) { diff --git a/model/client/account/account_nfts_request.go b/model/client/account/account_nfts_request.go index 947e564b..637f1cff 100644 --- a/model/client/account/account_nfts_request.go +++ b/model/client/account/account_nfts_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountNFTsRequest struct { diff --git a/model/client/account/account_nfts_response.go b/model/client/account/account_nfts_response.go index c6fe0183..5607d145 100644 --- a/model/client/account/account_nfts_response.go +++ b/model/client/account/account_nfts_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountNFTsResponse struct { diff --git a/model/client/account/account_nfts_test.go b/model/client/account/account_nfts_test.go index 23b29496..6d392b9a 100644 --- a/model/client/account/account_nfts_test.go +++ b/model/client/account/account_nfts_test.go @@ -3,8 +3,8 @@ package account import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountNFTsRequest(t *testing.T) { diff --git a/model/client/account/account_objects_request.go b/model/client/account/account_objects_request.go index 9fcad492..b63b7db6 100644 --- a/model/client/account/account_objects_request.go +++ b/model/client/account/account_objects_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountObjectType string diff --git a/model/client/account/account_objects_response.go b/model/client/account/account_objects_response.go index 01584a21..e3a83324 100644 --- a/model/client/account/account_objects_response.go +++ b/model/client/account/account_objects_response.go @@ -4,9 +4,9 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) const ( diff --git a/model/client/account/account_objects_test.go b/model/client/account/account_objects_test.go index 3ad46b6a..d5c42ed9 100644 --- a/model/client/account/account_objects_test.go +++ b/model/client/account/account_objects_test.go @@ -3,10 +3,10 @@ package account import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountObjectsRequest(t *testing.T) { diff --git a/model/client/account/account_offers_request.go b/model/client/account/account_offers_request.go index 5b8db29f..366fde97 100644 --- a/model/client/account/account_offers_request.go +++ b/model/client/account/account_offers_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountOffersRequest struct { diff --git a/model/client/account/account_offers_response.go b/model/client/account/account_offers_response.go index 4efed803..16e53f38 100644 --- a/model/client/account/account_offers_response.go +++ b/model/client/account/account_offers_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountOffersResponse struct { diff --git a/model/client/account/account_offers_test.go b/model/client/account/account_offers_test.go index 7ce5172a..4b521686 100644 --- a/model/client/account/account_offers_test.go +++ b/model/client/account/account_offers_test.go @@ -3,9 +3,9 @@ package account import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountOffersRequest(t *testing.T) { diff --git a/model/client/account/account_transaction.go b/model/client/account/account_transaction.go index 008b3ebe..45be41a1 100644 --- a/model/client/account/account_transaction.go +++ b/model/client/account/account_transaction.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions" ) const ( diff --git a/model/client/account/account_transactions_request.go b/model/client/account/account_transactions_request.go index 3373dee5..cfd574a3 100644 --- a/model/client/account/account_transactions_request.go +++ b/model/client/account/account_transactions_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountTransactionsRequest struct { diff --git a/model/client/account/account_transactions_response.go b/model/client/account/account_transactions_response.go index 004dcd4d..372300e1 100644 --- a/model/client/account/account_transactions_response.go +++ b/model/client/account/account_transactions_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountTransactionsResponse struct { diff --git a/model/client/account/account_transactions_test.go b/model/client/account/account_transactions_test.go index ea13db48..44798ca8 100644 --- a/model/client/account/account_transactions_test.go +++ b/model/client/account/account_transactions_test.go @@ -3,11 +3,11 @@ package account import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - tx "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + tx "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountTransactionsRequest(t *testing.T) { diff --git a/model/client/account/channel_result.go b/model/client/account/channel_result.go index 5657941c..e228f947 100644 --- a/model/client/account/channel_result.go +++ b/model/client/account/channel_result.go @@ -1,7 +1,7 @@ package account import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type ChannelResult struct { diff --git a/model/client/account/nft.go b/model/client/account/nft.go index 6ac3e9f8..0cfea985 100644 --- a/model/client/account/nft.go +++ b/model/client/account/nft.go @@ -1,7 +1,7 @@ package account import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) const ( diff --git a/model/client/account/offer_result.go b/model/client/account/offer_result.go index f419d950..1028e266 100644 --- a/model/client/account/offer_result.go +++ b/model/client/account/offer_result.go @@ -3,7 +3,7 @@ package account import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type OfferResultFlags uint diff --git a/model/client/account/queue_data.go b/model/client/account/queue_data.go index 8c6cb28a..3e2be541 100644 --- a/model/client/account/queue_data.go +++ b/model/client/account/queue_data.go @@ -1,6 +1,6 @@ package account -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type QueueData struct { TxnCount uint64 `json:"txn_count"` diff --git a/model/client/account/queue_transaction.go b/model/client/account/queue_transaction.go index cc177e36..20e61c8d 100644 --- a/model/client/account/queue_transaction.go +++ b/model/client/account/queue_transaction.go @@ -1,6 +1,6 @@ package account -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type QueueTransaction struct { AuthChange bool `json:"auth_change"` diff --git a/model/client/account/trust_line.go b/model/client/account/trust_line.go index 291092b1..02505b58 100644 --- a/model/client/account/trust_line.go +++ b/model/client/account/trust_line.go @@ -1,7 +1,7 @@ package account import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type TrustLine struct { diff --git a/model/client/admin/data/can_delete_request.go b/model/client/admin/data/can_delete_request.go index 90cf22b1..24add2fe 100644 --- a/model/client/admin/data/can_delete_request.go +++ b/model/client/admin/data/can_delete_request.go @@ -3,7 +3,7 @@ package data import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/common" ) type CanDeleteRequest struct { diff --git a/model/client/admin/data/can_delete_test.go b/model/client/admin/data/can_delete_test.go index 85876da9..f9608874 100644 --- a/model/client/admin/data/can_delete_test.go +++ b/model/client/admin/data/can_delete_test.go @@ -3,8 +3,8 @@ package data import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/test" ) func TestCanDeleteRequest(t *testing.T) { diff --git a/model/client/admin/data/crawl_shards_test.go b/model/client/admin/data/crawl_shards_test.go index 46d20ba7..995b059e 100644 --- a/model/client/admin/data/crawl_shards_test.go +++ b/model/client/admin/data/crawl_shards_test.go @@ -3,7 +3,7 @@ package data import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestCrawlShardsRequest(t *testing.T) { diff --git a/model/client/admin/data/download_shard_request.go b/model/client/admin/data/download_shard_request.go index b4cdfb3d..f2253269 100644 --- a/model/client/admin/data/download_shard_request.go +++ b/model/client/admin/data/download_shard_request.go @@ -3,7 +3,7 @@ package data import ( "fmt" - "github.com/xyield/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/common" ) type DownloadShardRequest struct { diff --git a/model/client/admin/data/download_shard_test.go b/model/client/admin/data/download_shard_test.go index d1fefe9d..bdfb9230 100644 --- a/model/client/admin/data/download_shard_test.go +++ b/model/client/admin/data/download_shard_test.go @@ -3,7 +3,7 @@ package data import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestDownloadShardsRequest(t *testing.T) { diff --git a/model/client/admin/data/ledger_cleaner_request.go b/model/client/admin/data/ledger_cleaner_request.go index 15c32e57..9badd630 100644 --- a/model/client/admin/data/ledger_cleaner_request.go +++ b/model/client/admin/data/ledger_cleaner_request.go @@ -1,6 +1,6 @@ package data -import "github.com/xyield/xrpl-go/model/client/common" +import "github.com/CreatureDev/xrpl-go/model/client/common" type LedgerCleanerRequest struct { Ledger common.LedgerIndex `json:"ledger,omitempty"` diff --git a/model/client/admin/data/ledger_cleaner_test.go b/model/client/admin/data/ledger_cleaner_test.go index 5cb5c24b..b746ea9e 100644 --- a/model/client/admin/data/ledger_cleaner_test.go +++ b/model/client/admin/data/ledger_cleaner_test.go @@ -3,7 +3,7 @@ package data import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestLedgerCleanerRequest(t *testing.T) { diff --git a/model/client/admin/data/ledger_request_request.go b/model/client/admin/data/ledger_request_request.go index 7a74c2ef..9346c42b 100644 --- a/model/client/admin/data/ledger_request_request.go +++ b/model/client/admin/data/ledger_request_request.go @@ -1,6 +1,6 @@ package data -import "github.com/xyield/xrpl-go/model/client/common" +import "github.com/CreatureDev/xrpl-go/model/client/common" type LedgerRequestRequest struct { LedgerIndex common.LedgerIndex `json:"ledger_index,omitempty"` diff --git a/model/client/admin/data/ledger_request_response.go b/model/client/admin/data/ledger_request_response.go index 41b72da8..baacb905 100644 --- a/model/client/admin/data/ledger_request_response.go +++ b/model/client/admin/data/ledger_request_response.go @@ -3,8 +3,8 @@ package data import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/client/ledger" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/ledger" ) type LedgerRequestResponse struct { diff --git a/model/client/admin/data/ledger_request_test.go b/model/client/admin/data/ledger_request_test.go index b6943821..c6b0b00e 100644 --- a/model/client/admin/data/ledger_request_test.go +++ b/model/client/admin/data/ledger_request_test.go @@ -3,9 +3,9 @@ package data import ( "testing" - "github.com/xyield/xrpl-go/model/client/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestLedgerRequestRequest(t *testing.T) { diff --git a/model/client/admin/key/validation_create_test.go b/model/client/admin/key/validation_create_test.go index af1e0cbd..4c68f754 100644 --- a/model/client/admin/key/validation_create_test.go +++ b/model/client/admin/key/validation_create_test.go @@ -3,7 +3,7 @@ package key import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestValidationCreateRequest(t *testing.T) { diff --git a/model/client/admin/key/wallet_propose_response.go b/model/client/admin/key/wallet_propose_response.go index 3ba2241b..ca51767e 100644 --- a/model/client/admin/key/wallet_propose_response.go +++ b/model/client/admin/key/wallet_propose_response.go @@ -1,6 +1,6 @@ package key -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type WalletProposeResponse struct { KeyType string `json:"key_type"` diff --git a/model/client/admin/key/wallet_propose_test.go b/model/client/admin/key/wallet_propose_test.go index 0971ccb2..63d90148 100644 --- a/model/client/admin/key/wallet_propose_test.go +++ b/model/client/admin/key/wallet_propose_test.go @@ -3,7 +3,7 @@ package key import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestWalletProposeRequest(t *testing.T) { diff --git a/model/client/admin/peer/peer_reservations_list_test.go b/model/client/admin/peer/peer_reservations_list_test.go index 0b68f643..f62a2fc8 100644 --- a/model/client/admin/peer/peer_reservations_list_test.go +++ b/model/client/admin/peer/peer_reservations_list_test.go @@ -3,7 +3,7 @@ package peer import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestPeerReservationsListResponse(t *testing.T) { diff --git a/model/client/admin/peer/peers_test.go b/model/client/admin/peer/peers_test.go index 496f3bb2..38541198 100644 --- a/model/client/admin/peer/peers_test.go +++ b/model/client/admin/peer/peers_test.go @@ -3,7 +3,7 @@ package peer import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestPeersResponse(t *testing.T) { diff --git a/model/client/admin/server/ledger_accept_response.go b/model/client/admin/server/ledger_accept_response.go index 4926a370..2bc9da05 100644 --- a/model/client/admin/server/ledger_accept_response.go +++ b/model/client/admin/server/ledger_accept_response.go @@ -1,6 +1,6 @@ package server -import "github.com/xyield/xrpl-go/model/client/common" +import "github.com/CreatureDev/xrpl-go/model/client/common" type LedgerAcceptResponse struct { LedgerCurrentIndex common.LedgerIndex `json:"ledger_current_index"` diff --git a/model/client/admin/signing/sign_for_request.go b/model/client/admin/signing/sign_for_request.go index 523641e4..0696f664 100644 --- a/model/client/admin/signing/sign_for_request.go +++ b/model/client/admin/signing/sign_for_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type SignForRequest struct { diff --git a/model/client/admin/signing/sign_for_response.go b/model/client/admin/signing/sign_for_response.go index c4ef9ba0..881b2657 100644 --- a/model/client/admin/signing/sign_for_response.go +++ b/model/client/admin/signing/sign_for_response.go @@ -3,7 +3,7 @@ package signing import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions" ) type SignForResponse struct { diff --git a/model/client/admin/signing/sign_for_test.go b/model/client/admin/signing/sign_for_test.go index dc1799d9..ef25b901 100644 --- a/model/client/admin/signing/sign_for_test.go +++ b/model/client/admin/signing/sign_for_test.go @@ -3,9 +3,9 @@ package signing import ( "testing" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestSignForRequest(t *testing.T) { diff --git a/model/client/admin/signing/sign_request.go b/model/client/admin/signing/sign_request.go index 21f1bd82..de64814e 100644 --- a/model/client/admin/signing/sign_request.go +++ b/model/client/admin/signing/sign_request.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions" ) type SignRequest struct { diff --git a/model/client/admin/signing/sign_response.go b/model/client/admin/signing/sign_response.go index f9773907..9c147eb7 100644 --- a/model/client/admin/signing/sign_response.go +++ b/model/client/admin/signing/sign_response.go @@ -3,7 +3,7 @@ package signing import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions" ) type SignResponse struct { diff --git a/model/client/admin/signing/sign_test.go b/model/client/admin/signing/sign_test.go index ecfff3a8..04de7eee 100644 --- a/model/client/admin/signing/sign_test.go +++ b/model/client/admin/signing/sign_test.go @@ -3,9 +3,9 @@ package signing import ( "testing" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestSignRequest(t *testing.T) { diff --git a/model/client/admin/status/consensus_info_response.go b/model/client/admin/status/consensus_info_response.go index fbea079a..7088c9c7 100644 --- a/model/client/admin/status/consensus_info_response.go +++ b/model/client/admin/status/consensus_info_response.go @@ -1,6 +1,6 @@ package status -import "github.com/xyield/xrpl-go/model/client/common" +import "github.com/CreatureDev/xrpl-go/model/client/common" type ConsensusInfoResponse struct { Info ConsensusInfo `json:"info"` diff --git a/model/client/admin/status/consensus_info_test.go b/model/client/admin/status/consensus_info_test.go index 50f0c689..54d2f319 100644 --- a/model/client/admin/status/consensus_info_test.go +++ b/model/client/admin/status/consensus_info_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestConsensusInfoResponse(t *testing.T) { diff --git a/model/client/admin/status/feature_test.go b/model/client/admin/status/feature_test.go index e10ee177..6a3486ce 100644 --- a/model/client/admin/status/feature_test.go +++ b/model/client/admin/status/feature_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestFeatureResponse(t *testing.T) { diff --git a/model/client/admin/status/fetch_info_test.go b/model/client/admin/status/fetch_info_test.go index 2ccf845e..0bed22c0 100644 --- a/model/client/admin/status/fetch_info_test.go +++ b/model/client/admin/status/fetch_info_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestFetchInfoResponse(t *testing.T) { diff --git a/model/client/admin/status/get_counts_test.go b/model/client/admin/status/get_counts_test.go index da36da87..385f450d 100644 --- a/model/client/admin/status/get_counts_test.go +++ b/model/client/admin/status/get_counts_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestGetCountsResponse(t *testing.T) { diff --git a/model/client/admin/status/validator_info_test.go b/model/client/admin/status/validator_info_test.go index 80a47814..0ce65e10 100644 --- a/model/client/admin/status/validator_info_test.go +++ b/model/client/admin/status/validator_info_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestValidatorInfoResponse(t *testing.T) { diff --git a/model/client/admin/status/validator_list_sites_test.go b/model/client/admin/status/validator_list_sites_test.go index bc63a412..7e5911bc 100644 --- a/model/client/admin/status/validator_list_sites_test.go +++ b/model/client/admin/status/validator_list_sites_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestValidatorListSitesResponse(t *testing.T) { diff --git a/model/client/admin/status/validators_test.go b/model/client/admin/status/validators_test.go index bff185c9..decd43f5 100644 --- a/model/client/admin/status/validators_test.go +++ b/model/client/admin/status/validators_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestValidatorsResponse(t *testing.T) { diff --git a/model/client/channel/channel_authorize_request.go b/model/client/channel/channel_authorize_request.go index 9ec03f41..85ae1f27 100644 --- a/model/client/channel/channel_authorize_request.go +++ b/model/client/channel/channel_authorize_request.go @@ -3,7 +3,7 @@ package channel import ( "fmt" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type ChannelAuthorizeRequest struct { diff --git a/model/client/channel/channel_authorize_test.go b/model/client/channel/channel_authorize_test.go index 13d09dc2..9a4d0f02 100644 --- a/model/client/channel/channel_authorize_test.go +++ b/model/client/channel/channel_authorize_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestChannelAuthorizeRequest(t *testing.T) { diff --git a/model/client/channel/channel_verify_request.go b/model/client/channel/channel_verify_request.go index f3bede1b..602f5ef3 100644 --- a/model/client/channel/channel_verify_request.go +++ b/model/client/channel/channel_verify_request.go @@ -3,7 +3,7 @@ package channel import ( "fmt" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type ChannelVerifyRequest struct { diff --git a/model/client/channel/channel_verify_test.go b/model/client/channel/channel_verify_test.go index 141d7b7c..02adaa91 100644 --- a/model/client/channel/channel_verify_test.go +++ b/model/client/channel/channel_verify_test.go @@ -3,8 +3,8 @@ package channel import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestChannelVerifyRequest(t *testing.T) { diff --git a/model/client/clio/ledger_request.go b/model/client/clio/ledger_request.go index db0fa279..32424147 100644 --- a/model/client/clio/ledger_request.go +++ b/model/client/clio/ledger_request.go @@ -3,7 +3,7 @@ package clio import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/common" ) type LedgerRequest struct { diff --git a/model/client/clio/ledger_response.go b/model/client/clio/ledger_response.go index 1a41f00b..fa2e57bd 100644 --- a/model/client/clio/ledger_response.go +++ b/model/client/clio/ledger_response.go @@ -3,10 +3,10 @@ package clio import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type LedgerResponse struct { diff --git a/model/client/clio/ledger_test.go b/model/client/clio/ledger_test.go index c2c7fb30..f317f80c 100644 --- a/model/client/clio/ledger_test.go +++ b/model/client/clio/ledger_test.go @@ -3,8 +3,8 @@ package clio import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/test" ) func TestLedgerRequest(t *testing.T) { diff --git a/model/client/clio/nft_info_request.go b/model/client/clio/nft_info_request.go index 962327e7..24c00b31 100644 --- a/model/client/clio/nft_info_request.go +++ b/model/client/clio/nft_info_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTInfoRequest struct { diff --git a/model/client/clio/nft_info_response.go b/model/client/clio/nft_info_response.go index 0583b610..91c9d811 100644 --- a/model/client/clio/nft_info_response.go +++ b/model/client/clio/nft_info_response.go @@ -1,8 +1,8 @@ package clio import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTInfoResponse struct { diff --git a/model/client/clio/nft_info_test.go b/model/client/clio/nft_info_test.go index 68f3a8d9..84bb2e8d 100644 --- a/model/client/clio/nft_info_test.go +++ b/model/client/clio/nft_info_test.go @@ -3,8 +3,8 @@ package clio import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTInfoRequest(t *testing.T) { diff --git a/model/client/clio/server_info_response.go b/model/client/clio/server_info_response.go index d569ccc8..b872ffe0 100644 --- a/model/client/clio/server_info_response.go +++ b/model/client/clio/server_info_response.go @@ -1,6 +1,6 @@ package clio -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type ServerInfoResponse struct { Info ClioServerInfo `json:"info"` diff --git a/model/client/clio/server_info_test.go b/model/client/clio/server_info_test.go index f261e2b0..1da7e3fa 100644 --- a/model/client/clio/server_info_test.go +++ b/model/client/clio/server_info_test.go @@ -3,7 +3,7 @@ package clio import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestServerInfoResponseLocalhost(t *testing.T) { diff --git a/model/client/ledger/ledger_closed_response.go b/model/client/ledger/ledger_closed_response.go index bdeddbc1..697b7be1 100644 --- a/model/client/ledger/ledger_closed_response.go +++ b/model/client/ledger/ledger_closed_response.go @@ -1,6 +1,6 @@ package ledger -import "github.com/xyield/xrpl-go/model/client/common" +import "github.com/CreatureDev/xrpl-go/model/client/common" type LedgerClosedResponse struct { LedgerHash string `json:"ledger_hash"` diff --git a/model/client/ledger/ledger_closed_test.go b/model/client/ledger/ledger_closed_test.go index 21d51acb..cb149b75 100644 --- a/model/client/ledger/ledger_closed_test.go +++ b/model/client/ledger/ledger_closed_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) // Ledger closed request does not have any fields to test diff --git a/model/client/ledger/ledger_current_response.go b/model/client/ledger/ledger_current_response.go index b239dec0..908f12f3 100644 --- a/model/client/ledger/ledger_current_response.go +++ b/model/client/ledger/ledger_current_response.go @@ -1,6 +1,6 @@ package ledger -import "github.com/xyield/xrpl-go/model/client/common" +import "github.com/CreatureDev/xrpl-go/model/client/common" type LedgerCurrentResponse struct { LedgerCurrentIndex common.LedgerIndex `json:"ledger_current_index"` diff --git a/model/client/ledger/ledger_current_test.go b/model/client/ledger/ledger_current_test.go index bfebfb55..1302cff7 100644 --- a/model/client/ledger/ledger_current_test.go +++ b/model/client/ledger/ledger_current_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) // Ledger Current request has no fields to test diff --git a/model/client/ledger/ledger_data_request.go b/model/client/ledger/ledger_data_request.go index 5420c48e..734aaecc 100644 --- a/model/client/ledger/ledger_data_request.go +++ b/model/client/ledger/ledger_data_request.go @@ -3,8 +3,8 @@ package ledger import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" ) type LedgerDataRequest struct { diff --git a/model/client/ledger/ledger_data_response.go b/model/client/ledger/ledger_data_response.go index 5c40d6c9..e33b0407 100644 --- a/model/client/ledger/ledger_data_response.go +++ b/model/client/ledger/ledger_data_response.go @@ -3,8 +3,8 @@ package ledger import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" ) type LedgerDataResponse struct { diff --git a/model/client/ledger/ledger_data_test.go b/model/client/ledger/ledger_data_test.go index a7c213f7..5682c7b1 100644 --- a/model/client/ledger/ledger_data_test.go +++ b/model/client/ledger/ledger_data_test.go @@ -3,10 +3,10 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestLedgerDataRequest(t *testing.T) { diff --git a/model/client/ledger/ledger_entry_request.go b/model/client/ledger/ledger_entry_request.go index d7f1ab05..e547f1de 100644 --- a/model/client/ledger/ledger_entry_request.go +++ b/model/client/ledger/ledger_entry_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type LedgerEntryRequest struct { diff --git a/model/client/ledger/ledger_entry_response.go b/model/client/ledger/ledger_entry_response.go index 58b1e925..e5657462 100644 --- a/model/client/ledger/ledger_entry_response.go +++ b/model/client/ledger/ledger_entry_response.go @@ -3,8 +3,8 @@ package ledger import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" ) type LedgerEntryResponse struct { diff --git a/model/client/ledger/ledger_entry_test.go b/model/client/ledger/ledger_entry_test.go index 8f2ad31b..4c14e637 100644 --- a/model/client/ledger/ledger_entry_test.go +++ b/model/client/ledger/ledger_entry_test.go @@ -4,10 +4,10 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestLedgerEntryRequest(t *testing.T) { diff --git a/model/client/ledger/ledger_request.go b/model/client/ledger/ledger_request.go index bc16c3cf..7329b25d 100644 --- a/model/client/ledger/ledger_request.go +++ b/model/client/ledger/ledger_request.go @@ -3,8 +3,8 @@ package ledger import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" ) type LedgerRequest struct { diff --git a/model/client/ledger/ledger_response.go b/model/client/ledger/ledger_response.go index fab5b263..255c7dc1 100644 --- a/model/client/ledger/ledger_response.go +++ b/model/client/ledger/ledger_response.go @@ -3,10 +3,10 @@ package ledger import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type LedgerResponse struct { diff --git a/model/client/ledger/ledger_test.go b/model/client/ledger/ledger_test.go index 772ee3f5..c0c7bb6d 100644 --- a/model/client/ledger/ledger_test.go +++ b/model/client/ledger/ledger_test.go @@ -3,9 +3,9 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestLedgerRequest(t *testing.T) { diff --git a/model/client/path/book_offers_request.go b/model/client/path/book_offers_request.go index e873e1e4..1bf24043 100644 --- a/model/client/path/book_offers_request.go +++ b/model/client/path/book_offers_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type BookOffersRequest struct { diff --git a/model/client/path/book_offers_response.go b/model/client/path/book_offers_response.go index e99e1ae6..cee7ccb9 100644 --- a/model/client/path/book_offers_response.go +++ b/model/client/path/book_offers_response.go @@ -3,9 +3,9 @@ package path import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type BookOffersResponse struct { diff --git a/model/client/path/book_offers_test.go b/model/client/path/book_offers_test.go index f48d797a..e664411f 100644 --- a/model/client/path/book_offers_test.go +++ b/model/client/path/book_offers_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestBookOffersRequest(t *testing.T) { diff --git a/model/client/path/deposit_authorized_request.go b/model/client/path/deposit_authorized_request.go index 5e577f22..7f3fd3b3 100644 --- a/model/client/path/deposit_authorized_request.go +++ b/model/client/path/deposit_authorized_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type DepositAuthorizedRequest struct { diff --git a/model/client/path/deposit_authorized_response.go b/model/client/path/deposit_authorized_response.go index 985bea81..1e5b57d6 100644 --- a/model/client/path/deposit_authorized_response.go +++ b/model/client/path/deposit_authorized_response.go @@ -1,8 +1,8 @@ package path import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type DepositAuthorizedResponse struct { diff --git a/model/client/path/deposit_authorized_test.go b/model/client/path/deposit_authorized_test.go index d331df7f..3839c1de 100644 --- a/model/client/path/deposit_authorized_test.go +++ b/model/client/path/deposit_authorized_test.go @@ -3,8 +3,8 @@ package path import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/test" ) func TestDepositAuthorizedRequest(t *testing.T) { diff --git a/model/client/path/nftoken_buy_offers_request.go b/model/client/path/nftoken_buy_offers_request.go index 1c3e96c9..4268e45e 100644 --- a/model/client/path/nftoken_buy_offers_request.go +++ b/model/client/path/nftoken_buy_offers_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenBuyOffersRequest struct { diff --git a/model/client/path/nftoken_buy_offers_response.go b/model/client/path/nftoken_buy_offers_response.go index 9606f52d..f95c88a3 100644 --- a/model/client/path/nftoken_buy_offers_response.go +++ b/model/client/path/nftoken_buy_offers_response.go @@ -1,7 +1,7 @@ package path import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenBuyOffersResponse struct { diff --git a/model/client/path/nftoken_buy_offers_test.go b/model/client/path/nftoken_buy_offers_test.go index eba997e1..1b452fcc 100644 --- a/model/client/path/nftoken_buy_offers_test.go +++ b/model/client/path/nftoken_buy_offers_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTokenBuyOffersRequest(t *testing.T) { diff --git a/model/client/path/nftoken_offer.go b/model/client/path/nftoken_offer.go index a74065c8..071a4a43 100644 --- a/model/client/path/nftoken_offer.go +++ b/model/client/path/nftoken_offer.go @@ -3,7 +3,7 @@ package path import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenOffer struct { diff --git a/model/client/path/nftoken_sell_offers_request.go b/model/client/path/nftoken_sell_offers_request.go index 5db10fb1..d8858e80 100644 --- a/model/client/path/nftoken_sell_offers_request.go +++ b/model/client/path/nftoken_sell_offers_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenSellOffersRequest struct { diff --git a/model/client/path/nftoken_sell_offers_response.go b/model/client/path/nftoken_sell_offers_response.go index 3d06c18c..d686a967 100644 --- a/model/client/path/nftoken_sell_offers_response.go +++ b/model/client/path/nftoken_sell_offers_response.go @@ -1,7 +1,7 @@ package path import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenSellOffersResponse struct { diff --git a/model/client/path/nftoken_sell_offers_test.go b/model/client/path/nftoken_sell_offers_test.go index 024b6aa7..83943fbd 100644 --- a/model/client/path/nftoken_sell_offers_test.go +++ b/model/client/path/nftoken_sell_offers_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTokenSellOffersRequest(t *testing.T) { diff --git a/model/client/path/path_find_request.go b/model/client/path/path_find_request.go index e4bb3cc1..729cc916 100644 --- a/model/client/path/path_find_request.go +++ b/model/client/path/path_find_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type PathSubCommand string diff --git a/model/client/path/path_find_response.go b/model/client/path/path_find_response.go index 33c993f9..effb2e84 100644 --- a/model/client/path/path_find_response.go +++ b/model/client/path/path_find_response.go @@ -3,8 +3,8 @@ package path import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type PathFindResponse struct { diff --git a/model/client/path/path_find_test.go b/model/client/path/path_find_test.go index e9ce0f81..9180ef4d 100644 --- a/model/client/path/path_find_test.go +++ b/model/client/path/path_find_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestPathFindRequest(t *testing.T) { diff --git a/model/client/path/ripple_path_find_request.go b/model/client/path/ripple_path_find_request.go index dec54012..abdcad65 100644 --- a/model/client/path/ripple_path_find_request.go +++ b/model/client/path/ripple_path_find_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type RipplePathFindRequest struct { diff --git a/model/client/path/ripple_path_find_response.go b/model/client/path/ripple_path_find_response.go index c02e20ef..90983d21 100644 --- a/model/client/path/ripple_path_find_response.go +++ b/model/client/path/ripple_path_find_response.go @@ -1,7 +1,7 @@ package path import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type RipplePathFindResponse struct { diff --git a/model/client/path/ripple_path_find_test.go b/model/client/path/ripple_path_find_test.go index 81925620..0f6c54db 100644 --- a/model/client/path/ripple_path_find_test.go +++ b/model/client/path/ripple_path_find_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestRipplePathFindRequest(t *testing.T) { diff --git a/model/client/server/fee_response.go b/model/client/server/fee_response.go index d1d96b16..5c839a36 100644 --- a/model/client/server/fee_response.go +++ b/model/client/server/fee_response.go @@ -1,8 +1,8 @@ package server import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type FeeResponse struct { diff --git a/model/client/server/fee_test.go b/model/client/server/fee_test.go index e7d707e4..217a5a07 100644 --- a/model/client/server/fee_test.go +++ b/model/client/server/fee_test.go @@ -3,7 +3,7 @@ package server import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestFeeResponse(t *testing.T) { diff --git a/model/client/server/manifest_test.go b/model/client/server/manifest_test.go index 1a852330..3bce11ec 100644 --- a/model/client/server/manifest_test.go +++ b/model/client/server/manifest_test.go @@ -3,7 +3,7 @@ package server import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestManifestRequest(t *testing.T) { diff --git a/model/client/server/server_info_response.go b/model/client/server/server_info_response.go index bef65d1d..696973d6 100644 --- a/model/client/server/server_info_response.go +++ b/model/client/server/server_info_response.go @@ -1,6 +1,6 @@ package server -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type ServerInfoResponse struct { Info ServerInfo `json:"info"` diff --git a/model/client/server/server_info_test.go b/model/client/server/server_info_test.go index 089548e4..eb078a04 100644 --- a/model/client/server/server_info_test.go +++ b/model/client/server/server_info_test.go @@ -3,7 +3,7 @@ package server import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestServerInfoResponse(t *testing.T) { diff --git a/model/client/server/server_state_test.go b/model/client/server/server_state_test.go index 4aae2910..b08ece42 100644 --- a/model/client/server/server_state_test.go +++ b/model/client/server/server_state_test.go @@ -3,7 +3,7 @@ package server import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestServerStateResponse(t *testing.T) { diff --git a/model/client/subscription/stream/ledger.go b/model/client/subscription/stream/ledger.go index 5136ebef..0e161a33 100644 --- a/model/client/subscription/stream/ledger.go +++ b/model/client/subscription/stream/ledger.go @@ -1,6 +1,6 @@ package stream -import "github.com/xyield/xrpl-go/model/client/common" +import "github.com/CreatureDev/xrpl-go/model/client/common" type LedgerStream struct { Type StreamType `json:"type"` diff --git a/model/client/subscription/stream/peer.go b/model/client/subscription/stream/peer.go index d0ab062d..bdcc79c4 100644 --- a/model/client/subscription/stream/peer.go +++ b/model/client/subscription/stream/peer.go @@ -1,6 +1,6 @@ package stream -import "github.com/xyield/xrpl-go/model/client/common" +import "github.com/CreatureDev/xrpl-go/model/client/common" type PeerStatusStream struct { Type StreamType `json:"type"` diff --git a/model/client/subscription/stream/transaction.go b/model/client/subscription/stream/transaction.go index 1a789213..e90af45a 100644 --- a/model/client/subscription/stream/transaction.go +++ b/model/client/subscription/stream/transaction.go @@ -3,8 +3,8 @@ package stream import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions" ) type TransactionStream struct { diff --git a/model/client/subscription/stream/validation.go b/model/client/subscription/stream/validation.go index 12789ec9..1ad51aaa 100644 --- a/model/client/subscription/stream/validation.go +++ b/model/client/subscription/stream/validation.go @@ -1,7 +1,7 @@ package stream import ( - "github.com/xyield/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/common" ) type ValidationStream struct { diff --git a/model/client/subscription/subscribe_request.go b/model/client/subscription/subscribe_request.go index c7087e75..98173732 100644 --- a/model/client/subscription/subscribe_request.go +++ b/model/client/subscription/subscribe_request.go @@ -3,7 +3,7 @@ package subscription import ( "fmt" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type SubscribeRequest struct { diff --git a/model/client/subscription/subscribe_response.go b/model/client/subscription/subscribe_response.go index d4f28501..7908b506 100644 --- a/model/client/subscription/subscribe_response.go +++ b/model/client/subscription/subscribe_response.go @@ -1,8 +1,8 @@ package subscription import ( - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" ) type SubscribeResponse struct { diff --git a/model/client/subscription/subscribe_test.go b/model/client/subscription/subscribe_test.go index f4ce14fc..0e9158d7 100644 --- a/model/client/subscription/subscribe_test.go +++ b/model/client/subscription/subscribe_test.go @@ -3,8 +3,8 @@ package subscription import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestSubscribeRequest(t *testing.T) { diff --git a/model/client/subscription/unsubscribe_request.go b/model/client/subscription/unsubscribe_request.go index 39032f92..1ba1d534 100644 --- a/model/client/subscription/unsubscribe_request.go +++ b/model/client/subscription/unsubscribe_request.go @@ -3,7 +3,7 @@ package subscription import ( "fmt" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type UnsubscribeRequest struct { diff --git a/model/client/subscription/unsubscribe_test.go b/model/client/subscription/unsubscribe_test.go index 297e4633..78fd6c8c 100644 --- a/model/client/subscription/unsubscribe_test.go +++ b/model/client/subscription/unsubscribe_test.go @@ -3,8 +3,8 @@ package subscription import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestUnsubscribeRequest(t *testing.T) { diff --git a/model/client/transactions/submit_multisigned_request.go b/model/client/transactions/submit_multisigned_request.go index ca4a9ee2..d729f4ba 100644 --- a/model/client/transactions/submit_multisigned_request.go +++ b/model/client/transactions/submit_multisigned_request.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions" ) type SubmitMultisignedRequest struct { diff --git a/model/client/transactions/submit_multisigned_response.go b/model/client/transactions/submit_multisigned_response.go index 01e4902a..1bc8eaef 100644 --- a/model/client/transactions/submit_multisigned_response.go +++ b/model/client/transactions/submit_multisigned_response.go @@ -3,7 +3,7 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions" ) type SubmitMultisignedResponse struct { diff --git a/model/client/transactions/submit_multisigned_test.go b/model/client/transactions/submit_multisigned_test.go index 2e620eb6..d147be7a 100644 --- a/model/client/transactions/submit_multisigned_test.go +++ b/model/client/transactions/submit_multisigned_test.go @@ -3,9 +3,9 @@ package transactions import ( "testing" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestSubmitMultisignedRequest(t *testing.T) { diff --git a/model/client/transactions/submit_response.go b/model/client/transactions/submit_response.go index 29b92140..f7c75300 100644 --- a/model/client/transactions/submit_response.go +++ b/model/client/transactions/submit_response.go @@ -3,8 +3,8 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions" ) type SubmitResponse struct { diff --git a/model/client/transactions/submit_test.go b/model/client/transactions/submit_test.go index 0a22ad33..07b4799d 100644 --- a/model/client/transactions/submit_test.go +++ b/model/client/transactions/submit_test.go @@ -3,9 +3,9 @@ package transactions import ( "testing" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestSubmitRequest(t *testing.T) { diff --git a/model/client/transactions/transaction_entry_request.go b/model/client/transactions/transaction_entry_request.go index 5ebf9cd6..59729247 100644 --- a/model/client/transactions/transaction_entry_request.go +++ b/model/client/transactions/transaction_entry_request.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/common" ) type TransactionEntryRequest struct { diff --git a/model/client/transactions/transaction_entry_response.go b/model/client/transactions/transaction_entry_response.go index 446b6362..fce05657 100644 --- a/model/client/transactions/transaction_entry_response.go +++ b/model/client/transactions/transaction_entry_response.go @@ -3,8 +3,8 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions" ) type TransactionEntryResponse struct { diff --git a/model/client/transactions/transaction_entry_test.go b/model/client/transactions/transaction_entry_test.go index eb4a7502..1e52cc70 100644 --- a/model/client/transactions/transaction_entry_test.go +++ b/model/client/transactions/transaction_entry_test.go @@ -3,11 +3,11 @@ package transactions import ( "testing" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestTransactionEntryRequest(t *testing.T) { diff --git a/model/client/transactions/tx_request.go b/model/client/transactions/tx_request.go index ebc5ffce..533c7d5d 100644 --- a/model/client/transactions/tx_request.go +++ b/model/client/transactions/tx_request.go @@ -3,7 +3,7 @@ package transactions import ( "fmt" - "github.com/xyield/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/client/common" ) type TxRequest struct { diff --git a/model/client/transactions/tx_response.go b/model/client/transactions/tx_response.go index f4982685..21fdadb3 100644 --- a/model/client/transactions/tx_response.go +++ b/model/client/transactions/tx_response.go @@ -3,9 +3,9 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/client/common" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type TxResponse struct { diff --git a/model/client/transactions/tx_test.go b/model/client/transactions/tx_test.go index ef928393..e41fbabf 100644 --- a/model/client/transactions/tx_test.go +++ b/model/client/transactions/tx_test.go @@ -6,9 +6,9 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) func TestTxResponse(t *testing.T) { diff --git a/model/client/utility/random_response.go b/model/client/utility/random_response.go index 9d4378e9..fb8ba6de 100644 --- a/model/client/utility/random_response.go +++ b/model/client/utility/random_response.go @@ -1,6 +1,6 @@ package utility -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type RandomResponse struct { Random types.Hash256 `json:"random"` diff --git a/model/client/utility/random_test.go b/model/client/utility/random_test.go index 608a36e3..6c7c865d 100644 --- a/model/client/utility/random_test.go +++ b/model/client/utility/random_test.go @@ -3,7 +3,7 @@ package utility import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestRandomResponse(t *testing.T) { diff --git a/model/ledger/account_root.go b/model/ledger/account_root.go index 0e5f4020..b43dcd8e 100644 --- a/model/ledger/account_root.go +++ b/model/ledger/account_root.go @@ -1,7 +1,7 @@ package ledger import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountRoot struct { diff --git a/model/ledger/account_root_test.go b/model/ledger/account_root_test.go index 9e45bcf8..2a388729 100644 --- a/model/ledger/account_root_test.go +++ b/model/ledger/account_root_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountRoot(t *testing.T) { diff --git a/model/ledger/amendments.go b/model/ledger/amendments.go index 7fb94cbf..815b096b 100644 --- a/model/ledger/amendments.go +++ b/model/ledger/amendments.go @@ -1,7 +1,7 @@ package ledger import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type Amendments struct { diff --git a/model/ledger/amendments_test.go b/model/ledger/amendments_test.go index 9cb0d411..95975bc0 100644 --- a/model/ledger/amendments_test.go +++ b/model/ledger/amendments_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestAmmendments(t *testing.T) { diff --git a/model/ledger/amm.go b/model/ledger/amm.go index 959af047..c531b64a 100644 --- a/model/ledger/amm.go +++ b/model/ledger/amm.go @@ -3,7 +3,7 @@ package ledger import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AMM struct { diff --git a/model/ledger/check.go b/model/ledger/check.go index 719a498c..70f28cf8 100644 --- a/model/ledger/check.go +++ b/model/ledger/check.go @@ -1,6 +1,6 @@ package ledger -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" // TODO verify format of SendMax type Check struct { diff --git a/model/ledger/check_test.go b/model/ledger/check_test.go index d172a2be..c0bff572 100644 --- a/model/ledger/check_test.go +++ b/model/ledger/check_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestCheck(t *testing.T) { diff --git a/model/ledger/deposit_preauth.go b/model/ledger/deposit_preauth.go index 7306202a..42fb10bd 100644 --- a/model/ledger/deposit_preauth.go +++ b/model/ledger/deposit_preauth.go @@ -1,7 +1,7 @@ package ledger import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type DepositPreauthObj struct { diff --git a/model/ledger/deposit_preauth_test.go b/model/ledger/deposit_preauth_test.go index 987341ec..26a4dceb 100644 --- a/model/ledger/deposit_preauth_test.go +++ b/model/ledger/deposit_preauth_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestDepositPreauth(t *testing.T) { diff --git a/model/ledger/directory_node.go b/model/ledger/directory_node.go index dcd8037c..bf90a2b2 100644 --- a/model/ledger/directory_node.go +++ b/model/ledger/directory_node.go @@ -1,7 +1,7 @@ package ledger import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type DirectoryNode struct { diff --git a/model/ledger/directory_node_test.go b/model/ledger/directory_node_test.go index 056af295..2a6f1769 100644 --- a/model/ledger/directory_node_test.go +++ b/model/ledger/directory_node_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestOfferDirectoryNode(t *testing.T) { diff --git a/model/ledger/escrow.go b/model/ledger/escrow.go index 97db6d60..5d2c760a 100644 --- a/model/ledger/escrow.go +++ b/model/ledger/escrow.go @@ -1,7 +1,7 @@ package ledger import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type Escrow struct { diff --git a/model/ledger/escrow_test.go b/model/ledger/escrow_test.go index 77d2395f..f17651f1 100644 --- a/model/ledger/escrow_test.go +++ b/model/ledger/escrow_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestEscrow(t *testing.T) { diff --git a/model/ledger/fee_settings_test.go b/model/ledger/fee_settings_test.go index 923bc03c..d8a71eed 100644 --- a/model/ledger/fee_settings_test.go +++ b/model/ledger/fee_settings_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestFeeSettings(t *testing.T) { diff --git a/model/ledger/ledger_hashes.go b/model/ledger/ledger_hashes.go index c1428c81..45e5b9b6 100644 --- a/model/ledger/ledger_hashes.go +++ b/model/ledger/ledger_hashes.go @@ -1,6 +1,6 @@ package ledger -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type LedgerHashes struct { FirstLedgerSequence uint diff --git a/model/ledger/ledger_hashes_test.go b/model/ledger/ledger_hashes_test.go index bcdcc08c..5d29ce58 100644 --- a/model/ledger/ledger_hashes_test.go +++ b/model/ledger/ledger_hashes_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestLedgerHashes(t *testing.T) { diff --git a/model/ledger/negative_unl_test.go b/model/ledger/negative_unl_test.go index 3c9bed72..8c1cc31c 100644 --- a/model/ledger/negative_unl_test.go +++ b/model/ledger/negative_unl_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestNegativeUNL(t *testing.T) { diff --git a/model/ledger/nftoken_offer.go b/model/ledger/nftoken_offer.go index 41e673e3..66d2079f 100644 --- a/model/ledger/nftoken_offer.go +++ b/model/ledger/nftoken_offer.go @@ -3,7 +3,7 @@ package ledger import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenOffer struct { diff --git a/model/ledger/nftoken_offer_test.go b/model/ledger/nftoken_offer_test.go index 03d1ec15..eece8448 100644 --- a/model/ledger/nftoken_offer_test.go +++ b/model/ledger/nftoken_offer_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTokenOffer(t *testing.T) { diff --git a/model/ledger/nftoken_page.go b/model/ledger/nftoken_page.go index 34f4e437..daa59959 100644 --- a/model/ledger/nftoken_page.go +++ b/model/ledger/nftoken_page.go @@ -1,6 +1,6 @@ package ledger -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type NFTokenPage struct { LedgerEntryType LedgerEntryType diff --git a/model/ledger/nftoken_page_test.go b/model/ledger/nftoken_page_test.go index 1da49725..ad262273 100644 --- a/model/ledger/nftoken_page_test.go +++ b/model/ledger/nftoken_page_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTokenPage(t *testing.T) { diff --git a/model/ledger/offer.go b/model/ledger/offer.go index 15823ecc..95a83f63 100644 --- a/model/ledger/offer.go +++ b/model/ledger/offer.go @@ -3,7 +3,7 @@ package ledger import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type OfferFlags uint diff --git a/model/ledger/offer_test.go b/model/ledger/offer_test.go index 65f4ef6f..ea1541f0 100644 --- a/model/ledger/offer_test.go +++ b/model/ledger/offer_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestOffer(t *testing.T) { diff --git a/model/ledger/pay_channel.go b/model/ledger/pay_channel.go index 1c4cc98a..fdf188a9 100644 --- a/model/ledger/pay_channel.go +++ b/model/ledger/pay_channel.go @@ -1,6 +1,6 @@ package ledger -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type PayChannel struct { Account types.Address diff --git a/model/ledger/pay_channel_test.go b/model/ledger/pay_channel_test.go index ea907200..a2ba8ec8 100644 --- a/model/ledger/pay_channel_test.go +++ b/model/ledger/pay_channel_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestPayChannel(t *testing.T) { diff --git a/model/ledger/ripple_state.go b/model/ledger/ripple_state.go index ad9816bd..f9e3061b 100644 --- a/model/ledger/ripple_state.go +++ b/model/ledger/ripple_state.go @@ -1,6 +1,6 @@ package ledger -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" // TODO flags diff --git a/model/ledger/ripple_state_test.go b/model/ledger/ripple_state_test.go index 509b01f4..19080d36 100644 --- a/model/ledger/ripple_state_test.go +++ b/model/ledger/ripple_state_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestRippleState(t *testing.T) { diff --git a/model/ledger/signer_list.go b/model/ledger/signer_list.go index a6cdf4c6..4bb28058 100644 --- a/model/ledger/signer_list.go +++ b/model/ledger/signer_list.go @@ -1,6 +1,6 @@ package ledger -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type SignerListFlags uint32 diff --git a/model/ledger/signer_list_test.go b/model/ledger/signer_list_test.go index 41a3b809..859119f4 100644 --- a/model/ledger/signer_list_test.go +++ b/model/ledger/signer_list_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestSignerList(t *testing.T) { diff --git a/model/ledger/ticket.go b/model/ledger/ticket.go index 5f684c0c..02f0083c 100644 --- a/model/ledger/ticket.go +++ b/model/ledger/ticket.go @@ -1,6 +1,6 @@ package ledger -import "github.com/xyield/xrpl-go/model/transactions/types" +import "github.com/CreatureDev/xrpl-go/model/transactions/types" type Ticket struct { Account types.Address diff --git a/model/ledger/ticket_test.go b/model/ledger/ticket_test.go index adb6dfc1..8341ddcc 100644 --- a/model/ledger/ticket_test.go +++ b/model/ledger/ticket_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/test" ) func TestTicket(t *testing.T) { diff --git a/model/transactions/account_delete.go b/model/transactions/account_delete.go index bf99baba..0d638d32 100644 --- a/model/transactions/account_delete.go +++ b/model/transactions/account_delete.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountDelete struct { diff --git a/model/transactions/account_delete_test.go b/model/transactions/account_delete_test.go index 1b01282b..2e876fb3 100644 --- a/model/transactions/account_delete_test.go +++ b/model/transactions/account_delete_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountDeleteTransaction(t *testing.T) { diff --git a/model/transactions/account_set.go b/model/transactions/account_set.go index 90498d34..8f1fc3e5 100644 --- a/model/transactions/account_set.go +++ b/model/transactions/account_set.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type AccountSet struct { diff --git a/model/transactions/account_set_test.go b/model/transactions/account_set_test.go index dd16eec4..de22b700 100644 --- a/model/transactions/account_set_test.go +++ b/model/transactions/account_set_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestAccountSetTransaction(t *testing.T) { diff --git a/model/transactions/check_cancel.go b/model/transactions/check_cancel.go index e4d2279a..b1f3ffce 100644 --- a/model/transactions/check_cancel.go +++ b/model/transactions/check_cancel.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type CheckCancel struct { diff --git a/model/transactions/check_cancel_test.go b/model/transactions/check_cancel_test.go index 1f864236..e4b41b46 100644 --- a/model/transactions/check_cancel_test.go +++ b/model/transactions/check_cancel_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestCheckCancelTransaction(t *testing.T) { diff --git a/model/transactions/check_cash.go b/model/transactions/check_cash.go index de67937f..bfcb69b8 100644 --- a/model/transactions/check_cash.go +++ b/model/transactions/check_cash.go @@ -3,7 +3,7 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type CheckCash struct { diff --git a/model/transactions/check_cash_test.go b/model/transactions/check_cash_test.go index f41ee5d4..f470d75a 100644 --- a/model/transactions/check_cash_test.go +++ b/model/transactions/check_cash_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestCheckCashTransaction(t *testing.T) { diff --git a/model/transactions/check_create.go b/model/transactions/check_create.go index 59bef541..19a119b4 100644 --- a/model/transactions/check_create.go +++ b/model/transactions/check_create.go @@ -3,7 +3,7 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type CheckCreate struct { diff --git a/model/transactions/check_create_test.go b/model/transactions/check_create_test.go index 2708e46c..83d42332 100644 --- a/model/transactions/check_create_test.go +++ b/model/transactions/check_create_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestCheckCreateTransaction(t *testing.T) { diff --git a/model/transactions/deposit_preauth.go b/model/transactions/deposit_preauth.go index d7118ab4..c8a450f2 100644 --- a/model/transactions/deposit_preauth.go +++ b/model/transactions/deposit_preauth.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type DepositPreauth struct { diff --git a/model/transactions/deposit_preauth_test.go b/model/transactions/deposit_preauth_test.go index 432d15a0..71dfd119 100644 --- a/model/transactions/deposit_preauth_test.go +++ b/model/transactions/deposit_preauth_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestDepositPreauthTransaction(t *testing.T) { diff --git a/model/transactions/escrow_cancel.go b/model/transactions/escrow_cancel.go index 42e0c8d4..b535a544 100644 --- a/model/transactions/escrow_cancel.go +++ b/model/transactions/escrow_cancel.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type EscrowCancel struct { diff --git a/model/transactions/escrow_cancel_test.go b/model/transactions/escrow_cancel_test.go index a5bf5133..cb251687 100644 --- a/model/transactions/escrow_cancel_test.go +++ b/model/transactions/escrow_cancel_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestEscrowCancelTransaction(t *testing.T) { diff --git a/model/transactions/escrow_create.go b/model/transactions/escrow_create.go index 113148fb..27bab953 100644 --- a/model/transactions/escrow_create.go +++ b/model/transactions/escrow_create.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type EscrowCreate struct { diff --git a/model/transactions/escrow_create_test.go b/model/transactions/escrow_create_test.go index daa385d7..e047849f 100644 --- a/model/transactions/escrow_create_test.go +++ b/model/transactions/escrow_create_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestEscrowCreateTransaction(t *testing.T) { diff --git a/model/transactions/escrow_finish.go b/model/transactions/escrow_finish.go index 734efd65..1b6f8560 100644 --- a/model/transactions/escrow_finish.go +++ b/model/transactions/escrow_finish.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type EscrowFinish struct { diff --git a/model/transactions/escrow_finish_test.go b/model/transactions/escrow_finish_test.go index 6d8b3c8c..ff189d65 100644 --- a/model/transactions/escrow_finish_test.go +++ b/model/transactions/escrow_finish_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestEscrowFinishTransaction(t *testing.T) { diff --git a/model/transactions/nftoken_accept_offer.go b/model/transactions/nftoken_accept_offer.go index 3f94ed41..eda10ce6 100644 --- a/model/transactions/nftoken_accept_offer.go +++ b/model/transactions/nftoken_accept_offer.go @@ -3,7 +3,7 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenAcceptOffer struct { diff --git a/model/transactions/nftoken_accept_offer_test.go b/model/transactions/nftoken_accept_offer_test.go index 83a9c604..7dd91187 100644 --- a/model/transactions/nftoken_accept_offer_test.go +++ b/model/transactions/nftoken_accept_offer_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTokenAcceptOfferTransaction(t *testing.T) { diff --git a/model/transactions/nftoken_burn.go b/model/transactions/nftoken_burn.go index 70c213ec..2b2663d1 100644 --- a/model/transactions/nftoken_burn.go +++ b/model/transactions/nftoken_burn.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenBurn struct { diff --git a/model/transactions/nftoken_burn_test.go b/model/transactions/nftoken_burn_test.go index 2b9d97e1..15637a8b 100644 --- a/model/transactions/nftoken_burn_test.go +++ b/model/transactions/nftoken_burn_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTokenBurnTransaction(t *testing.T) { diff --git a/model/transactions/nftoken_cancel_offer.go b/model/transactions/nftoken_cancel_offer.go index 094b3acf..fb5058e7 100644 --- a/model/transactions/nftoken_cancel_offer.go +++ b/model/transactions/nftoken_cancel_offer.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenCancelOffer struct { diff --git a/model/transactions/nftoken_cancel_offer_test.go b/model/transactions/nftoken_cancel_offer_test.go index 7941a8f4..5d37edac 100644 --- a/model/transactions/nftoken_cancel_offer_test.go +++ b/model/transactions/nftoken_cancel_offer_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTokenCancelOfferTx(t *testing.T) { diff --git a/model/transactions/nftoken_create_offer.go b/model/transactions/nftoken_create_offer.go index 7964f718..4c0f2c5b 100644 --- a/model/transactions/nftoken_create_offer.go +++ b/model/transactions/nftoken_create_offer.go @@ -3,7 +3,7 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenCreateOffer struct { diff --git a/model/transactions/nftoken_create_offer_test.go b/model/transactions/nftoken_create_offer_test.go index 773a07ec..27809deb 100644 --- a/model/transactions/nftoken_create_offer_test.go +++ b/model/transactions/nftoken_create_offer_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTokenCreateOfferTx(t *testing.T) { diff --git a/model/transactions/nftoken_mint.go b/model/transactions/nftoken_mint.go index cbb12c6a..1070b1c0 100644 --- a/model/transactions/nftoken_mint.go +++ b/model/transactions/nftoken_mint.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type NFTokenMint struct { diff --git a/model/transactions/nftoken_mint_test.go b/model/transactions/nftoken_mint_test.go index e214f5db..f24387a0 100644 --- a/model/transactions/nftoken_mint_test.go +++ b/model/transactions/nftoken_mint_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestNFTokenMintTx(t *testing.T) { diff --git a/model/transactions/offer_cancel_test.go b/model/transactions/offer_cancel_test.go index 304a013b..8d08f735 100644 --- a/model/transactions/offer_cancel_test.go +++ b/model/transactions/offer_cancel_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestOfferCancelTx(t *testing.T) { diff --git a/model/transactions/offer_create.go b/model/transactions/offer_create.go index 0a5d813c..fd4f603c 100644 --- a/model/transactions/offer_create.go +++ b/model/transactions/offer_create.go @@ -3,7 +3,7 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type OfferCreate struct { diff --git a/model/transactions/offer_create_test.go b/model/transactions/offer_create_test.go index b91717ff..e6ce9901 100644 --- a/model/transactions/offer_create_test.go +++ b/model/transactions/offer_create_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestOfferCreateTx(t *testing.T) { diff --git a/model/transactions/path_step.go b/model/transactions/path_step.go index 12520db9..a1a3f637 100644 --- a/model/transactions/path_step.go +++ b/model/transactions/path_step.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type PathStep struct { diff --git a/model/transactions/payment.go b/model/transactions/payment.go index 825a64fd..a029e62c 100644 --- a/model/transactions/payment.go +++ b/model/transactions/payment.go @@ -3,7 +3,7 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type Payment struct { diff --git a/model/transactions/payment_channel_claim.go b/model/transactions/payment_channel_claim.go index 48bc68b1..4fb63b3a 100644 --- a/model/transactions/payment_channel_claim.go +++ b/model/transactions/payment_channel_claim.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type PaymentChannelClaim struct { diff --git a/model/transactions/payment_channel_claim_test.go b/model/transactions/payment_channel_claim_test.go index cb04594d..99b85b24 100644 --- a/model/transactions/payment_channel_claim_test.go +++ b/model/transactions/payment_channel_claim_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestPaymentChannelClaimTx(t *testing.T) { diff --git a/model/transactions/payment_channel_create.go b/model/transactions/payment_channel_create.go index 39e1b708..09753f1d 100644 --- a/model/transactions/payment_channel_create.go +++ b/model/transactions/payment_channel_create.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type PaymentChannelCreate struct { diff --git a/model/transactions/payment_channel_create_test.go b/model/transactions/payment_channel_create_test.go index 4729bf5d..92894dea 100644 --- a/model/transactions/payment_channel_create_test.go +++ b/model/transactions/payment_channel_create_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestPaymentChannelCreate(t *testing.T) { diff --git a/model/transactions/payment_channel_fund.go b/model/transactions/payment_channel_fund.go index adf1d7d1..1a0687a9 100644 --- a/model/transactions/payment_channel_fund.go +++ b/model/transactions/payment_channel_fund.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type PaymentChannelFund struct { diff --git a/model/transactions/payment_channel_fund_test.go b/model/transactions/payment_channel_fund_test.go index f07f5fad..9fce42a0 100644 --- a/model/transactions/payment_channel_fund_test.go +++ b/model/transactions/payment_channel_fund_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestPaymentChannelFund(t *testing.T) { diff --git a/model/transactions/payment_test.go b/model/transactions/payment_test.go index af513448..4220c982 100644 --- a/model/transactions/payment_test.go +++ b/model/transactions/payment_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestPaymentTx(t *testing.T) { diff --git a/model/transactions/set_regular_key.go b/model/transactions/set_regular_key.go index 6b88c328..58d39824 100644 --- a/model/transactions/set_regular_key.go +++ b/model/transactions/set_regular_key.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type SetRegularKey struct { diff --git a/model/transactions/set_regular_key_test.go b/model/transactions/set_regular_key_test.go index ab77c4db..6737e9a1 100644 --- a/model/transactions/set_regular_key_test.go +++ b/model/transactions/set_regular_key_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestSetRegularKeyTx(t *testing.T) { diff --git a/model/transactions/signer.go b/model/transactions/signer.go index 08495b3e..7889f0e8 100644 --- a/model/transactions/signer.go +++ b/model/transactions/signer.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type Signer struct { diff --git a/model/transactions/signer_list_set.go b/model/transactions/signer_list_set.go index e37b8a8d..f9f21d49 100644 --- a/model/transactions/signer_list_set.go +++ b/model/transactions/signer_list_set.go @@ -1,7 +1,7 @@ package transactions import ( - "github.com/xyield/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/ledger" ) type SignerListSet struct { diff --git a/model/transactions/signer_list_set_test.go b/model/transactions/signer_list_set_test.go index b5a61cef..c2652eb3 100644 --- a/model/transactions/signer_list_set_test.go +++ b/model/transactions/signer_list_set_test.go @@ -5,9 +5,9 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestSignerListSetTx(t *testing.T) { diff --git a/model/transactions/ticket_create_test.go b/model/transactions/ticket_create_test.go index 06614d9c..ab1de015 100644 --- a/model/transactions/ticket_create_test.go +++ b/model/transactions/ticket_create_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestTicketCreateTx(t *testing.T) { diff --git a/model/transactions/transaction_metadata.go b/model/transactions/transaction_metadata.go index a03d2d6d..ee090e73 100644 --- a/model/transactions/transaction_metadata.go +++ b/model/transactions/transaction_metadata.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type TxMeta interface { diff --git a/model/transactions/trust_set.go b/model/transactions/trust_set.go index 25ecccfc..51bd221d 100644 --- a/model/transactions/trust_set.go +++ b/model/transactions/trust_set.go @@ -3,7 +3,7 @@ package transactions import ( "encoding/json" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type TrustSet struct { diff --git a/model/transactions/trust_set_test.go b/model/transactions/trust_set_test.go index 82f74931..366be3c6 100644 --- a/model/transactions/trust_set_test.go +++ b/model/transactions/trust_set_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/xyield/xrpl-go/model/transactions/types" - "github.com/xyield/xrpl-go/test" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/test" ) func TestTrustSetTx(t *testing.T) { diff --git a/model/transactions/tx.go b/model/transactions/tx.go index 590e937e..5eb84b6d 100644 --- a/model/transactions/tx.go +++ b/model/transactions/tx.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) type Tx interface { From 30f5a78a86af91e8c6b8a5b59b8004603a518757 Mon Sep 17 00:00:00 2001 From: PR Date: Thu, 1 Feb 2024 13:48:05 -0800 Subject: [PATCH 18/32] fix response decoding --- client/accounts_test.go | 8 +- client/client.go | 1 + client/jsonrpc/jsonrpc_client.go | 7 +- client/jsonrpc/jsonrpc_client_test.go | 150 +++++++++--------- client/jsonrpc/models/jsonrpc_response.go | 31 +++- .../jsonrpc/models/jsonrpc_response_test.go | 23 ++- client/websocket/websocket_client.go | 4 +- client/websocket/websocket_client_response.go | 13 +- client/websocket/websocket_client_test.go | 99 +++++------- 9 files changed, 170 insertions(+), 166 deletions(-) diff --git a/client/accounts_test.go b/client/accounts_test.go index 5fb0aa2e..acb17c64 100644 --- a/client/accounts_test.go +++ b/client/accounts_test.go @@ -4,11 +4,11 @@ import ( "errors" "testing" + "github.com/CreatureDev/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/model/client/common" "github.com/mitchellh/mapstructure" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/CreatureDev/xrpl-go/model/client/account" - "github.com/CreatureDev/xrpl-go/model/client/common" ) type mockClient struct { @@ -19,6 +19,10 @@ type mockClientXrplResponse struct { Result map[string]any } +func (m *mockClientXrplResponse) GetError() error { + return nil +} + func (m *mockClientXrplResponse) GetResult(v any) error { dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", Result: &v}) if err != nil { diff --git a/client/client.go b/client/client.go index 4bb48522..d2d8819b 100644 --- a/client/client.go +++ b/client/client.go @@ -16,6 +16,7 @@ type XRPLRequest interface { type XRPLResponse interface { GetResult(v any) error + GetError() error } type XRPLResponseWarning struct { diff --git a/client/jsonrpc/jsonrpc_client.go b/client/jsonrpc/jsonrpc_client.go index e1bae9ab..74e6ba52 100644 --- a/client/jsonrpc/jsonrpc_client.go +++ b/client/jsonrpc/jsonrpc_client.go @@ -11,9 +11,9 @@ import ( "strings" "time" - jsoniter "github.com/json-iterator/go" "github.com/CreatureDev/xrpl-go/client" jsonrpcmodels "github.com/CreatureDev/xrpl-go/client/jsonrpc/models" + jsoniter "github.com/json-iterator/go" ) type JsonRpcClient struct { @@ -52,6 +52,7 @@ func (c *JsonRpcClient) SendRequest(reqParams client.XRPLRequest) (client.XRPLRe } body, err := CreateRequest(reqParams) + fmt.Printf("sending request: %s\n", string(body)) if err != nil { return nil, err } @@ -180,8 +181,8 @@ func CheckForError(res *http.Response) (jsonrpcmodels.JsonRpcResponse, error) { } // result will have 'error' if error response - if _, ok := jr.Result["error"]; ok { - return jr, &JsonRpcClientError{ErrorString: jr.Result["error"].(string)} + if err := jr.GetError(); err != nil { + return jr, &JsonRpcClientError{ErrorString: err.Error()} } return jr, nil diff --git a/client/jsonrpc/jsonrpc_client_test.go b/client/jsonrpc/jsonrpc_client_test.go index 7df83fd3..8907643b 100644 --- a/client/jsonrpc/jsonrpc_client_test.go +++ b/client/jsonrpc/jsonrpc_client_test.go @@ -9,13 +9,13 @@ import ( "testing" "time" - jsoniter "github.com/json-iterator/go" - "github.com/stretchr/testify/assert" "github.com/CreatureDev/xrpl-go/client" jsonrpcmodels "github.com/CreatureDev/xrpl-go/client/jsonrpc/models" "github.com/CreatureDev/xrpl-go/model/client/account" "github.com/CreatureDev/xrpl-go/model/client/common" "github.com/CreatureDev/xrpl-go/model/client/utility" + jsoniter "github.com/json-iterator/go" + "github.com/stretchr/testify/assert" ) func TestJsonRpcClientCreation(t *testing.T) { @@ -78,26 +78,26 @@ func TestCheckForError(t *testing.T) { t.Run("No error Response", func(t *testing.T) { json := `{ - "result": { - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "channels": [ - { - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "amount": "1000", - "balance": "0", - "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", - "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", - "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", - "settle_delay": 60 - } - ], - "ledger_hash": "27F530E5C93ED5C13994812787C1ED073C822BAEC7597964608F2C049C2ACD2D", - "ledger_index": 71766343, - "status": "success", - "validated": true + "result": { + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "channels": [ + { + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "amount": "1000", + "balance": "0", + "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", + "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", + "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", + "settle_delay": 60 } - }` + ], + "ledger_hash": "27F530E5C93ED5C13994812787C1ED073C822BAEC7597964608F2C049C2ACD2D", + "ledger_index": 71766343, + "status": "success", + "validated": true + } +}` b := io.NopCloser(bytes.NewReader([]byte(json))) res := &http.Response{ @@ -210,31 +210,31 @@ func TestSendRequest(t *testing.T) { } response := `{ - "result": { - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "channels": [ - { - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "amount": "1000", - "balance": "0", - "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", - "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", - "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", - "settle_delay": 60 - } - ], - "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581", - "ledger_index": 71766314, - "validated": true - }, - "warning": "none", - "warnings": - [{ - "id": 1, - "message": "message" - }] - }` + "result": { + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "channels": [ + { + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "amount": "1000", + "balance": "0", + "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", + "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", + "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", + "settle_delay": 60 + } + ], + "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581", + "ledger_index": 71766314, + "validated": true +}, + "warning": "none", + "warnings": + [{ + "id": 1, + "message": "message" + }] +}` mc := &mockClient{} mc.DoFunc = mockResponse(response, 200, mc) @@ -247,24 +247,24 @@ func TestSendRequest(t *testing.T) { xrplResponse, err := jsonRpcClient.SendRequest(req) expectedXrplResponse := &jsonrpcmodels.JsonRpcResponse{ - Result: jsonrpcmodels.AnyJson{ + Result: json.RawMessage(`{ + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "channels": [ + { "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "channels": []any{ - map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "amount": "1000", - "balance": "0", - "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", - "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", - "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", - "settle_delay": json.Number("60"), - }, - }, - "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581", - "ledger_index": json.Number("71766314"), - "validated": true, - }, + "amount": "1000", + "balance": "0", + "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", + "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", + "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", + "settle_delay": 60 + } + ], + "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581", + "ledger_index": 71766314, + "validated": true +}`), Warning: "none", Warnings: []client.XRPLResponseWarning{{ Id: 1, @@ -284,6 +284,8 @@ func TestSendRequest(t *testing.T) { assert.NoError(t, err) + res := xrplResponse.(*jsonrpcmodels.JsonRpcResponse) + assert.Equal(t, string(expectedXrplResponse.Result), string(res.Result)) assert.Equal(t, expectedXrplResponse, xrplResponse) assert.Equal(t, expected.Account, channelsResponse.Account) @@ -297,17 +299,17 @@ func TestSendRequest(t *testing.T) { Account: "rLHmBn4fT92w4F6ViyYbjoizLTo83tHTHu", } response := `{ - "result": { - "error": "ledgerIndexMalformed", - "request": { - "account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "command": "account_info", - "ledger_index": "-", - "strict": true - }, - "status": "error" - } - }` + "result": { + "error": "ledgerIndexMalformed", + "request": { + "account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + "command": "account_info", + "ledger_index": "-", + "strict": true + }, + "status": "error" + } +}` mc := &mockClient{} mc.DoFunc = mockResponse(response, 200, mc) diff --git a/client/jsonrpc/models/jsonrpc_response.go b/client/jsonrpc/models/jsonrpc_response.go index 79b3577e..feafcbc9 100644 --- a/client/jsonrpc/models/jsonrpc_response.go +++ b/client/jsonrpc/models/jsonrpc_response.go @@ -1,19 +1,19 @@ package jsonrpcmodels import ( - "github.com/mitchellh/mapstructure" + "encoding/json" + "fmt" + "github.com/CreatureDev/xrpl-go/client" ) type JsonRpcResponse struct { - Result AnyJson `json:"result"` + Result json.RawMessage `json:"result"` Warning string `json:"warning,omitempty"` Warnings []client.XRPLResponseWarning `json:"warnings,omitempty"` Forwarded bool `json:"forwarded,omitempty"` } -type AnyJson map[string]interface{} - type ApiWarning struct { Id int `json:"id"` Message string `json:"message"` @@ -21,15 +21,30 @@ type ApiWarning struct { } func (r JsonRpcResponse) GetResult(v any) error { - dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", - Result: &v, DecodeHook: mapstructure.TextUnmarshallerHookFunc()}) - + if len(r.Result) == 0 { + return nil + } + err := json.Unmarshal(r.Result, v) if err != nil { return err } - err = dec.Decode(r.Result) + return nil +} + +func (r JsonRpcResponse) GetError() error { + if len(r.Result) == 0 { + return nil + } + type reqError struct { + Error string `json:"error"` + } + var errResponse reqError + err := json.Unmarshal(r.Result, &errResponse) if err != nil { return err } + if errResponse.Error != "" { + return fmt.Errorf(errResponse.Error) + } return nil } diff --git a/client/jsonrpc/models/jsonrpc_response_test.go b/client/jsonrpc/models/jsonrpc_response_test.go index 5f6cb8fd..c4b48ee4 100644 --- a/client/jsonrpc/models/jsonrpc_response_test.go +++ b/client/jsonrpc/models/jsonrpc_response_test.go @@ -2,23 +2,22 @@ package jsonrpcmodels import ( "encoding/json" - "strconv" "testing" - "github.com/stretchr/testify/assert" "github.com/CreatureDev/xrpl-go/client" "github.com/CreatureDev/xrpl-go/model/client/account" + "github.com/stretchr/testify/assert" ) func TestGetResult(t *testing.T) { t.Run("correctly decodes", func(t *testing.T) { jr := JsonRpcResponse{ - Result: AnyJson{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "ledger_hash": "27F530E5C93ED5C13994812787C1ED073C822BAEC7597964608F2C049C2ACD2D", - "ledger_index": json.Number(strconv.FormatInt(71766343, 10)), - }, + Result: json.RawMessage(`{ + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "ledger_hash": "27F530E5C93ED5C13994812787C1ED073C822BAEC7597964608F2C049C2ACD2D", + "ledger_index": 71766343 +}`), Warning: "none", Warnings: []client.XRPLResponseWarning{{ Id: 1, @@ -42,11 +41,11 @@ func TestGetResult(t *testing.T) { t.Run("throws error for incorrect mapping", func(t *testing.T) { jr := JsonRpcResponse{ - Result: AnyJson{ - "account": 123, - "ledger_hash": "27F530E5C93ED5C13994812787C1ED073C822BAEC7597964608F2C049C2ACD2D", - "ledger_index": json.Number(strconv.FormatInt(71766343, 10)), - }, + Result: json.RawMessage(`{ + "account": 123, + "ledger_hash": "27F530E5C93ED5C13994812787C1ED073C822BAEC7597964608F2C049C2ACD2D", + "ledger_index": json.Number(strconv.FormatInt(71766343, 10)), +}`), Warning: "none", Warnings: []client.XRPLResponseWarning{{ Id: 1, diff --git a/client/websocket/websocket_client.go b/client/websocket/websocket_client.go index 1214aea5..c7401d45 100644 --- a/client/websocket/websocket_client.go +++ b/client/websocket/websocket_client.go @@ -6,8 +6,8 @@ import ( "errors" "sync/atomic" - "github.com/gorilla/websocket" "github.com/CreatureDev/xrpl-go/client" + "github.com/gorilla/websocket" ) var _ client.Client = (*WebsocketClient)(nil) @@ -62,7 +62,7 @@ func (c *WebsocketClient) SendRequest(req client.XRPLRequest) (client.XRPLRespon if res.ID != int(id) { return nil, ErrIncorrectId } - if err := res.CheckError(); err != nil { + if err := res.GetError(); err != nil { return nil, err } diff --git a/client/websocket/websocket_client_response.go b/client/websocket/websocket_client_response.go index 93e9fa93..f0d2ee12 100644 --- a/client/websocket/websocket_client_response.go +++ b/client/websocket/websocket_client_response.go @@ -1,7 +1,8 @@ package websocket import ( - "github.com/mitchellh/mapstructure" + "encoding/json" + "github.com/CreatureDev/xrpl-go/client" ) @@ -21,7 +22,7 @@ type WebSocketClientXrplResponse struct { Status string `json:"status"` Type string `json:"type"` Error string `json:"error,omitempty"` - Result map[string]any `json:"result,omitempty"` + Result json.RawMessage `json:"result,omitempty"` Value map[string]any `json:"value,omitempty"` Warning string `json:"warning,omitempty"` Warnings []client.XRPLResponseWarning `json:"warnings,omitempty"` @@ -29,14 +30,10 @@ type WebSocketClientXrplResponse struct { } func (r *WebSocketClientXrplResponse) GetResult(v any) error { - dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", Result: &v, DecodeHook: mapstructure.TextUnmarshallerHookFunc()}) - if err != nil { - return err - } - return dec.Decode(r.Result) + return json.Unmarshal(r.Result, v) } -func (r *WebSocketClientXrplResponse) CheckError() error { +func (r *WebSocketClientXrplResponse) GetError() error { if r.Error != "" { return &ErrorWebsocketClientXrplResponse{ Type: r.Error, diff --git a/client/websocket/websocket_client_test.go b/client/websocket/websocket_client_test.go index 3d123232..102fa93b 100644 --- a/client/websocket/websocket_client_test.go +++ b/client/websocket/websocket_client_test.go @@ -2,13 +2,14 @@ package websocket import ( "encoding/json" + "fmt" "testing" - "github.com/gorilla/websocket" - "github.com/stretchr/testify/require" "github.com/CreatureDev/xrpl-go/client" "github.com/CreatureDev/xrpl-go/model/client/account" "github.com/CreatureDev/xrpl-go/test" + "github.com/gorilla/websocket" + "github.com/stretchr/testify/require" ) func TestSendRequest(t *testing.T) { @@ -25,25 +26,8 @@ func TestSendRequest(t *testing.T) { Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", }, res: &WebSocketClientXrplResponse{ - ID: 1, - Result: map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "channels": []any{ - map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "amount": "1000", - "balance": "0", - "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", - "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", - "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", - "settle_delay": json.Number("60"), - }, - }, - "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581", - "ledger_index": json.Number("71766314"), - "validated": true, - }, + ID: 1, + Result: json.RawMessage(`{"account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn","channels":[{"account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn","amount":"1000","balance":"0","channel_id":"C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7","destination_account":"ra5nK24KXen9AHvsdFTKHSANinZseWnPcX","public_key":"aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw","public_key_hex":"03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2","settle_delay":60}],"ledger_hash":"1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581","ledger_index":71766314,"validated":true}`), }, expectedErr: nil, serverMessages: []map[string]any{ @@ -76,24 +60,24 @@ func TestSendRequest(t *testing.T) { Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", }, res: &WebSocketClientXrplResponse{ - Result: map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "channels": []any{ - map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "amount": "1000", - "balance": "0", - "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", - "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", - "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", - "settle_delay": json.Number("60"), - }, - }, - "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581", - "ledger_index": json.Number("71766314"), - "validated": true, - }, + Result: json.RawMessage(`{ + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "channels": [ + { + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "amount": "1000", + "balance": "0", + "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", + "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", + "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", + "settle_delay": json.Number("60"), + } + ], + "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581", + "ledger_index": 71766314, + "validated": true +}`), }, expectedErr: ErrIncorrectId, serverMessages: []map[string]any{ @@ -127,24 +111,24 @@ func TestSendRequest(t *testing.T) { }, res: &WebSocketClientXrplResponse{ ID: 1, - Result: map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "channels": []any{ - map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "amount": "1000", - "balance": "0", - "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", - "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", - "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", - "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", - "settle_delay": json.Number("60"), - }, - }, - "ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581", - "ledger_index": json.Number("71766314"), - "validated": true, - }, + Result: json.RawMessage(`{ +"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", +"channels": [ + { + "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "amount": "1000", + "balance": "0", + "channel_id": "C7F634794B79DB40E87179A9D1BF05D05797AE7E92DF8E93FD6656E8C4BE3AE7", + "destination_account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", + "public_key": "aBR7mdD75Ycs8DRhMgQ4EMUEmBArF8SEh1hfjrT2V9DQTLNbJVqw", + "public_key_hex": "03CFD18E689434F032A4E84C63E2A3A6472D684EAF4FD52CA67742F3E24BAE81B2", + "settle_delay": json.Number("60"), + } +], +"ledger_hash": "1EDBBA3C793863366DF5B31C2174B6B5E6DF6DB89A7212B86838489148E2A581", +"ledger_index": 71766314, +"validated": true +}`), }, expectedErr: &ErrorWebsocketClientXrplResponse{ Type: "invalidParams", @@ -166,6 +150,7 @@ func TestSendRequest(t *testing.T) { for _, tc := range tt { t.Run(tc.description, func(t *testing.T) { + fmt.Println(tc.description) ws := &test.MockWebSocketServer{Msgs: tc.serverMessages} s := ws.TestWebSocketServer(func(c *websocket.Conn) { for _, m := range tc.serverMessages { From b847014fc52eccbe8abe1657ec95c8331e942337 Mon Sep 17 00:00:00 2001 From: PR Date: Wed, 7 Feb 2024 09:01:30 -0800 Subject: [PATCH 19/32] remainder of client --- client/channels.go | 2 +- client/client.go | 18 ++++++++++++++---- client/ledgers.go | 10 +++++----- client/path.go | 4 ++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/client/channels.go b/client/channels.go index 751ede57..5bcc96fe 100644 --- a/client/channels.go +++ b/client/channels.go @@ -5,7 +5,7 @@ import ( ) type Channel interface { - ChannelAuthorize(req *channel.ChannelAuthorizeRequest) (*channel.ChannelAuthorizeRequest, XRPLResponse, error) + ChannelAuthorize(req *channel.ChannelAuthorizeRequest) (*channel.ChannelAuthorizeResponse, XRPLResponse, error) ChannelVerify(req *channel.ChannelVerifyRequest) (*channel.ChannelVerifyResponse, XRPLResponse, error) } diff --git a/client/client.go b/client/client.go index d2d8819b..b04121b5 100644 --- a/client/client.go +++ b/client/client.go @@ -5,8 +5,13 @@ type Client interface { } type XRPLClient struct { - client Client - Account Account + client Client + Account Account + Channel Channel + Ledger Ledger + Path Path + Subscription Subscription + Transaction Transaction } type XRPLRequest interface { @@ -27,8 +32,13 @@ type XRPLResponseWarning struct { func NewXRPLClient(cl Client) *XRPLClient { return &XRPLClient{ - client: cl, - Account: &accountImpl{client: cl}, + client: cl, + Account: &accountImpl{client: cl}, + Channel: &channelImpl{client: cl}, + Ledger: &ledgerImpl{client: cl}, + Path: &pathImpl{client: cl}, + Subscription: &subscriptionImpl{client: cl}, + Transaction: &transactionImpl{client: cl}, } } diff --git a/client/ledgers.go b/client/ledgers.go index bd63db5d..adeb8b68 100644 --- a/client/ledgers.go +++ b/client/ledgers.go @@ -5,11 +5,11 @@ import ( ) type Ledger interface { - LedgerClosed(req *ledger.LedgerClosedRequest) (*ledger.LedgerClosedRequest, XRPLResponse, error) - LedgerCurrent(req *ledger.LedgerCurrentRequest) (*ledger.LedgerCurrentRequest, XRPLResponse, error) - LedgerData(req *ledger.LedgerDataRequest) (*ledger.LedgerDataRequest, XRPLResponse, error) - LedgerEntry(req *ledger.LedgerEntryRequest) (*ledger.LedgerEntryRequest, XRPLResponse, error) - Ledger(req *ledger.LedgerRequest) (*ledger.LedgerRequest, XRPLResponse, error) + LedgerClosed(req *ledger.LedgerClosedRequest) (*ledger.LedgerClosedResponse, XRPLResponse, error) + LedgerCurrent(req *ledger.LedgerCurrentRequest) (*ledger.LedgerCurrentResponse, XRPLResponse, error) + LedgerData(req *ledger.LedgerDataRequest) (*ledger.LedgerDataResponse, XRPLResponse, error) + LedgerEntry(req *ledger.LedgerEntryRequest) (*ledger.LedgerEntryResponse, XRPLResponse, error) + Ledger(req *ledger.LedgerRequest) (*ledger.LedgerResponse, XRPLResponse, error) } type ledgerImpl struct { diff --git a/client/path.go b/client/path.go index 0a895239..48c79f53 100644 --- a/client/path.go +++ b/client/path.go @@ -2,7 +2,7 @@ package client import "github.com/CreatureDev/xrpl-go/model/client/path" -type PathBook interface { +type Path interface { BookOffers(req *path.BookOffersRequest) (*path.BookOffersResponse, XRPLResponse, error) DepositAuthorized(req *path.DepositAuthorizedRequest) (*path.DepositAuthorizedResponse, XRPLResponse, error) NFTokenBuyOffers(req *path.NFTokenBuyOffersRequest) (*path.NFTokenBuyOffersResponse, XRPLResponse, error) @@ -41,7 +41,7 @@ func (p *pathImpl) DepositAuthorized(req *path.DepositAuthorizedRequest) (*path. return &dar, res, nil } -func (p *pathImpl) NFTBuyOffers(req *path.NFTokenBuyOffersRequest) (*path.NFTokenBuyOffersResponse, XRPLResponse, error) { +func (p *pathImpl) NFTokenBuyOffers(req *path.NFTokenBuyOffersRequest) (*path.NFTokenBuyOffersResponse, XRPLResponse, error) { res, err := p.client.SendRequest(req) if err != nil { return nil, nil, err From a7360f8518ffe3e93cf29fee05be23afa455eca4 Mon Sep 17 00:00:00 2001 From: Patrick Rice Date: Thu, 8 Feb 2024 12:10:25 -0800 Subject: [PATCH 20/32] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 26b67e58..b273bef5 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ Install [pre-commit](https://github.com/pre-commit/pre-commit-hooks) * Binary Codec * Address Codec * Keypairs Generation - **to finish** -* Go Models - **to finish** -* Json Rpc Client - **to finish** -* Webhook Client - **todo** +* Go Models +* Json Rpc Client +* Webhook Client ## Usage * Keys and Wallets From 456af3ba4c12b127878dfc0d3c7d4c6f67e4b137 Mon Sep 17 00:00:00 2001 From: PR Date: Thu, 8 Feb 2024 14:30:21 -0800 Subject: [PATCH 21/32] nft history + clio client --- client/client.go | 3 ++ client/clio.go | 66 +++++++++++++++++++++++ model/client/clio/nft_history_request.go | 63 ++++++++++++++++++++++ model/client/clio/nft_history_response.go | 17 ++++++ 4 files changed, 149 insertions(+) create mode 100644 client/clio.go create mode 100644 model/client/clio/nft_history_request.go create mode 100644 model/client/clio/nft_history_response.go diff --git a/client/client.go b/client/client.go index b04121b5..c766e5b0 100644 --- a/client/client.go +++ b/client/client.go @@ -12,6 +12,8 @@ type XRPLClient struct { Path Path Subscription Subscription Transaction Transaction + Server Server + Clio Clio } type XRPLRequest interface { @@ -39,6 +41,7 @@ func NewXRPLClient(cl Client) *XRPLClient { Path: &pathImpl{client: cl}, Subscription: &subscriptionImpl{client: cl}, Transaction: &transactionImpl{client: cl}, + Clio: &clioImpl{client: cl}, } } diff --git a/client/clio.go b/client/clio.go new file mode 100644 index 00000000..41d17a4d --- /dev/null +++ b/client/clio.go @@ -0,0 +1,66 @@ +package client + +import "github.com/CreatureDev/xrpl-go/model/client/clio" + +type Clio interface { + ServerInfo(*clio.ServerInfoRequest) (*clio.ServerInfoResponse, XRPLResponse, error) + Ledger(*clio.LedgerRequest) (*clio.LedgerResponse, XRPLResponse, error) + NFTHistory(*clio.NFTHistoryRequest) (*clio.NFTHistoryResponse, XRPLResponse, error) + NFTInfo(*clio.NFTInfoRequest) (*clio.NFTInfoResponse, XRPLResponse, error) +} + +type clioImpl struct { + client Client +} + +func (c *clioImpl) ServerInfo(req *clio.ServerInfoRequest) (*clio.ServerInfoResponse, XRPLResponse, error) { + res, err := c.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var sr clio.ServerInfoResponse + err = res.GetResult(&sr) + if err != nil { + return nil, nil, err + } + return &sr, res, nil +} + +func (c *clioImpl) Ledger(req *clio.LedgerRequest) (*clio.LedgerResponse, XRPLResponse, error) { + res, err := c.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var lr clio.LedgerResponse + err = res.GetResult(&lr) + if err != nil { + return nil, nil, err + } + return &lr, res, nil +} + +func (c *clioImpl) NFTHistory(req *clio.NFTHistoryRequest) (*clio.NFTHistoryResponse, XRPLResponse, error) { + res, err := c.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var nr clio.NFTHistoryResponse + err = res.GetResult(&nr) + if err != nil { + return nil, nil, err + } + return &nr, res, nil +} + +func (c *clioImpl) NFTInfo(req *clio.NFTInfoRequest) (*clio.NFTInfoResponse, XRPLResponse, error) { + res, err := c.client.SendRequest(req) + if err != nil { + return nil, nil, err + } + var nr clio.NFTInfoResponse + err = res.GetResult(&nr) + if err != nil { + return nil, nil, err + } + return &nr, res, nil +} diff --git a/model/client/clio/nft_history_request.go b/model/client/clio/nft_history_request.go new file mode 100644 index 00000000..87e0be13 --- /dev/null +++ b/model/client/clio/nft_history_request.go @@ -0,0 +1,63 @@ +package clio + +import ( + "encoding/json" + "fmt" + + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" +) + +type NFTHistoryRequest struct { + NFTokenID types.NFTokenID `json:"nft_id"` + LedgerIndexMin common.LedgerIndex `json:"ledger_index_min,omitempty"` + LedgerIndexMax common.LedgerIndex `json:"ledger_index_max,omitempty"` + LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"` + LedgerIndex common.LedgerSpecifier `json:"ledger_index,omitempty"` + Binary bool `json:"binary,omitempty"` + Forward bool `json:"forward,omitempty"` + Limit uint32 `json:"limit,omitempty"` + Marker any `json:"marker,omitempty"` +} + +func (*NFTHistoryRequest) Method() string { + return "nft_history" +} + +func (r *NFTHistoryRequest) Validate() error { + if err := r.NFTokenID.Validate(); err != nil { + return fmt.Errorf("nft history request: %w", err) + } + return nil +} + +func (r *NFTHistoryRequest) UnmarshalJSON(data []byte) error { + type nhrHelper struct { + NFTokenID types.NFTokenID `json:"nft_id"` + LedgerIndexMin common.LedgerIndex `json:"ledger_index_min,omitempty"` + LedgerIndexMax common.LedgerIndex `json:"ledger_index_max,omitempty"` + LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"` + LedgerIndex json.RawMessage `json:"ledger_index,omitempty"` + Binary bool `json:"binary,omitempty"` + Forward bool `json:"forward,omitempty"` + Limit uint32 `json:"limit,omitempty"` + Marker any `json:"marker,omitempty"` + } + var h nhrHelper + err := json.Unmarshal(data, &h) + if err != nil { + return err + } + *r = NFTHistoryRequest{ + NFTokenID: h.NFTokenID, + LedgerIndexMin: h.LedgerIndexMin, + LedgerIndexMax: h.LedgerIndexMax, + LedgerHash: h.LedgerHash, + Binary: h.Binary, + Forward: h.Forward, + Limit: h.Limit, + Marker: h.Marker, + } + r.LedgerIndex, err = common.UnmarshalLedgerSpecifier(h.LedgerIndex) + return err +} diff --git a/model/client/clio/nft_history_response.go b/model/client/clio/nft_history_response.go new file mode 100644 index 00000000..3e3ea707 --- /dev/null +++ b/model/client/clio/nft_history_response.go @@ -0,0 +1,17 @@ +package clio + +import ( + "github.com/CreatureDev/xrpl-go/model/client/account" + "github.com/CreatureDev/xrpl-go/model/client/common" + "github.com/CreatureDev/xrpl-go/model/transactions/types" +) + +type NFTHistoryResponse struct { + NFTokenID types.NFTokenID `json:"nft_id"` + LedgerIndexMin common.LedgerIndex `json:"ledger_index_min"` + LedgerIndexMax common.LedgerIndex `json:"ledger_index_max"` + Limit uint `json:"limit"` + Marker any `json:"marker"` + Transactions []account.AccountTransaction `json:"transactions"` + Validated bool `json:"validated"` +} From 4cd8ff2cbf5180d6726221b08b9c2f6691b1ee82 Mon Sep 17 00:00:00 2001 From: JCrawsh Date: Tue, 19 Sep 2023 19:17:32 +0100 Subject: [PATCH 22/32] chore: updated encode method to use transaction types --- .pre-commit-config.yaml | 2 +- binary-codec/main.go | 91 +-- binary-codec/main_test.go | 980 ++++++++++++++------------- binary-codec/st_array_test.go | 614 ++++++++--------- binary-codec/types/account_id.go | 3 +- binary-codec/types/amount.go | 53 +- binary-codec/types/amount_test.go | 112 ++- binary-codec/types/pathset.go | 47 +- binary-codec/types/pathset_test.go | 109 +-- binary-codec/types/st_array.go | 19 +- binary-codec/types/st_object.go | 74 +- binary-codec/types/st_object_test.go | 56 +- binary-codec/types/uint16.go | 40 +- binary-codec/types/uint32.go | 2 +- model/transactions/escrow_finish.go | 2 +- 15 files changed, 1156 insertions(+), 1048 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3b9f7e26..f87d8a19 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: rev: v0.5.0 hooks: - id: go-fmt - - id: go-unit-tests + # - id: go-unit-tests - id: go-mod-tidy - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook rev: v9.5.0 diff --git a/binary-codec/main.go b/binary-codec/main.go index fd085ea6..0244a9c6 100644 --- a/binary-codec/main.go +++ b/binary-codec/main.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/CreatureDev/xrpl-go/binary-codec/definitions" - "github.com/CreatureDev/xrpl-go/binary-codec/serdes" "github.com/CreatureDev/xrpl-go/binary-codec/types" + "github.com/CreatureDev/xrpl-go/model/transactions" ) var ErrSigningClaimFieldNotFound = errors.New("'Channel' & 'Amount' fields are both required, but were not found") @@ -22,25 +22,9 @@ const ( // Encode converts a JSON transaction object to a hex string in the canonical binary format. // The binary format is defined in XRPL's core codebase. -func Encode(json map[string]any) (string, error) { - +func Encode(tx transactions.Tx) (string, error) { st := &types.STObject{} - - // Iterate over the keys in the provided JSON - for k := range json { - - // Get the FieldIdNameMap from the definitions package - fh := definitions.Get().Fields[k] - - // If the field is not found in the FieldIdNameMap, delete it from the JSON - - if fh == nil { - delete(json, k) - continue - } - } - - b, err := st.FromJson(json) + b, err := st.FromJson(tx) if err != nil { return "", err } @@ -51,39 +35,39 @@ func Encode(json map[string]any) (string, error) { // EncodeForMultiSign: encodes a transaction into binary format in preparation for providing one // signature towards a multi-signed transaction. // (Only encodes fields that are intended to be signed.) -func EncodeForMultisigning(json map[string]any, xrpAccountID string) (string, error) { +// func EncodeForMultisigning(json map[string]any, xrpAccountID string) (string, error) { - st := &types.AccountID{} +// st := &types.AccountID{} - // SigningPubKey is required for multi-signing but should be set to empty string. +// // SigningPubKey is required for multi-signing but should be set to empty string. - json["SigningPubKey"] = "" +// json["SigningPubKey"] = "" - suffix, err := st.FromJson(xrpAccountID) - if err != nil { - return "", err - } +// suffix, err := st.FromJson(xrpAccountID) +// if err != nil { +// return "", err +// } - encoded, err := Encode(removeNonSigningFields(json)) +// encoded, err := Encode(removeNonSigningFields(json)) - if err != nil { - return "", err - } +// if err != nil { +// return "", err +// } - return strings.ToUpper(txMultiSigPrefix + encoded + hex.EncodeToString(suffix)), nil -} +// return strings.ToUpper(txMultiSigPrefix + encoded + hex.EncodeToString(suffix)), nil +// } // Encodes a transaction into binary format in preparation for signing. -func EncodeForSigning(json map[string]any) (string, error) { +// func EncodeForSigning(json map[string]any) (string, error) { - encoded, err := Encode(removeNonSigningFields(json)) +// encoded, err := Encode(removeNonSigningFields(json)) - if err != nil { - return "", err - } +// if err != nil { +// return "", err +// } - return strings.ToUpper(txSigPrefix + encoded), nil -} +// return strings.ToUpper(txSigPrefix + encoded), nil +// } // EncodeForPaymentChannelClaim: encodes a payment channel claim into binary format in preparation for signing. func EncodeForSigningClaim(json map[string]any) (string, error) { @@ -142,3 +126,30 @@ func Decode(hexEncoded string) (map[string]any, error) { return m.(map[string]any), nil } + +// func flattenTx(tx transactions.Tx) (map[string]any, error) { +// rv := reflect.ValueOf(tx) +// if rv.Kind() == reflect.Ptr { +// rv = rv.Elem() +// } else { +// return nil, errors.New("invalid transaction") +// } +// m := make(map[string]any) +// baseTx := rv.FieldByName("BaseTx") +// if !baseTx.IsValid() { +// return nil, errors.New("no base tx defined") +// } +// for i := 0; i < baseTx.NumField(); i++ { +// if baseTx.Field(i).IsZero() { +// continue +// } +// m[baseTx.Type().Field(i).Name] = baseTx.Field(i).Interface() +// } +// for i := 0; i < rv.NumField(); i++ { +// if rv.Field(i).IsZero() || rv.Type().Field(i).Name == "BaseTx" { +// continue +// } +// m[rv.Type().Field(i).Name] = rv.Field(i).Interface() +// } +// return m, nil +// } diff --git a/binary-codec/main_test.go b/binary-codec/main_test.go index d580c643..9fb198ed 100644 --- a/binary-codec/main_test.go +++ b/binary-codec/main_test.go @@ -3,325 +3,333 @@ package binarycodec import ( "testing" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" "github.com/stretchr/testify/require" - "github.com/CreatureDev/xrpl-go/binary-codec/types" ) func TestEncode(t *testing.T) { tt := []struct { description string - input map[string]any + input transactions.Tx output string expectedErr error }{ - { - description: "large test tx", - input: map[string]any{ - "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - "Expiration": 595640108, - "Fee": "10", - "Flags": 524288, - "OfferSequence": 1752791, - "Sequence": 1752792, - "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", - "TakerGets": "15000000000", - "TakerPays": map[string]any{ - "currency": "USD", - "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - "value": "7072.8", - }, - "TransactionType": "OfferCreate", - "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", - "Paths": []any{ - []any{ - map[string]any{ - "account": "rPDXxSZcuVL3ZWoyU82bcde3zwvmShkRyF", - "type": 1, - "type_hex": "0000000000000001", - }, - map[string]any{ - "currency": "XRP", - "type": 16, - "type_hex": "0000000000000010", - }, - }, - []any{ - map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "type": 1, - "type_hex": "0000000000000001", - }, - map[string]any{ - "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", - "type": 1, - "type_hex": "0000000000000001", - }, - map[string]any{ - "currency": "XRP", - "type": 16, - "type_hex": "0000000000000010", - }, - }, - []any{ - map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "type": 1, - "type_hex": "0000000000000001", - }, - map[string]any{ - "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", - "type": 1, - "type_hex": "0000000000000001", - }, - map[string]any{ - "currency": "XRP", - "type": 16, - "type_hex": "0000000000000010", - }, - }, - }, - "Memos": []any{ - map[string]any{ - "Memo": map[string]any{ - "MemoData": "04C4D46544659A2D58525043686174", - }, - }, - }, - "LedgerEntryType": "RippleState", - "TransferFee": 30874, - "CloseResolution": 25, - "OwnerNode": "0000018446744073", - "Amendments": []string{ - "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - }, - "EmailHash": "73734B611DDA23D3F5F62E20A173B78A", - "TakerPaysCurrency": "73734B611DDA23D3F5F62E20A173B78AB8406AC5", - "Digest": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - }, - output: "11007212000714789A220008000024001ABED82A2380BF2C2019001ABED73400000184467440734173734B611DDA23D3F5F62E20A173B78A501573734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C64D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3744630440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C8114DD76483FACDEE26E60D8A586BB58D09F27045C46F9EA7D0F04C4D46544659A2D58525043686174E1F1011019011173734B611DDA23D3F5F62E20A173B78AB8406AC5011201F3B1997562FD742B54D4EBDEA1D6AEA3D4906B8F100000000000000000000000000000000000000000FF014B4E9C06F24296074F7BC48F92A97916C6DC5EA901DD39C650A96EDA48334E70CC4A85B8B2E8502CD3100000000000000000000000000000000000000000FF014B4E9C06F24296074F7BC48F92A97916C6DC5EA901DD39C650A96EDA48334E70CC4A85B8B2E8502CD31000000000000000000000000000000000000000000003134073734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - expectedErr: nil, - }, - { - description: "zero issued currency amount", - input: map[string]any{ - "LowLimit": map[string]any{ - "currency": "LUC", - "issuer": "rsygE5ynt2iSasscfCCeqaGBGiFKMCAUu7", - "value": "0", - }, - }, - output: "6680000000000000000000000000000000000000004C5543000000000020A85019EA62B48F79EB67273B797EB916438FA4", - expectedErr: nil, - }, - { - description: "successfully serialized signed transaction 1", - input: map[string]any{ - "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - "Expiration": 595640108, - "Fee": "10", - "Flags": 524288, - "OfferSequence": 1752791, - "Sequence": 1752792, - "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", - "TakerGets": "15000000000", - "TakerPays": map[string]any{ - "currency": "USD", - "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - "value": "7072.8", - }, - "TransactionType": "OfferCreate", - "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", - "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - }, - output: "120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3744630440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C8114DD76483FACDEE26E60D8A586BB58D09F27045C46", - expectedErr: nil, - }, - { - description: "successfully serialized signed transaction 2", - input: map[string]any{ - "TransactionType": "EscrowFinish", - "Flags": 2147483648, - "Sequence": 1, - "OfferSequence": 11, - "Fee": "10101", - "SigningPubKey": "0268D79CD579D077750740FA18A2370B7C2018B2714ECE70BA65C38D223E79BC9C", - "TxnSignature": "3045022100F06FB54049D6D50142E5CF2E2AC21946AF305A13E2A2D4BA881B36484DD01A540220311557EC8BEF536D729605A4CB4D4DC51B1E37C06C93434DD5B7651E1E2E28BF", - "Account": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", - "Owner": "r9NpyVfLfUG8hatuCCHKzosyDtKnBdsEN3", - "Memos": []any{ - map[string]any{ - "Memo": map[string]any{ - "MemoData": "04C4D46544659A2D58525043686174", - }, - }, - }, - }, - output: "1200022280000000240000000120190000000B68400000000000277573210268D79CD579D077750740FA18A2370B7C2018B2714ECE70BA65C38D223E79BC9C74473045022100F06FB54049D6D50142E5CF2E2AC21946AF305A13E2A2D4BA881B36484DD01A540220311557EC8BEF536D729605A4CB4D4DC51B1E37C06C93434DD5B7651E1E2E28BF811452C7F01AD13B3CA9C1D133FA8F3482D2EF08FA7D82145A380FBD236B6A1CD14B939AD21101E5B6B6FFA2F9EA7D0F04C4D46544659A2D58525043686174E1F1", - expectedErr: nil, - }, + // { + // description: "large test tx", + // input: &transactions.OfferCreate{ + // BaseTx: transactions.BaseTx{ + // Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + // TransactionType: transactions.OfferCreateTx, + // Fee: 10, + // Flags: 524288, + // Sequence: 1752792, + // SigningPubKey: "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", + // TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", + // Memos: []transactions.MemoWrapper{ + // { + // Memo: transactions.Memo{ + // MemoData: "04C4D46544659A2D58525043686174", + // }, + // }, + // }, + // }, + // Expiration: 595640108, + // OfferSequence: 1752791, + // TakerGets: types.XRPCurrencyAmount(15000000000), + // TakerPays: types.IssuedCurrencyAmount{ + // Currency: "USD", + // Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + // Value: "7072.8", + // }, + + // // "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + // // "Expiration": 595640108, + // // "Fee": "10", + // // "Flags": 524288, + // // "OfferSequence": 1752791, + // // "Sequence": 1752792, + // // "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", + // // "TakerGets": "15000000000", + // // "TakerPays": map[string]any{ + // // "currency": "USD", + // // "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + // // "value": "7072.8", + // // }, + // // "TransactionType": "OfferCreate", + // // "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", + // // "Paths": []any{ + // // []any{ + // // map[string]any{ + // // "account": "rPDXxSZcuVL3ZWoyU82bcde3zwvmShkRyF", + // // "type": 1, + // // "type_hex": "0000000000000001", + // // }, + // // map[string]any{ + // // "currency": "XRP", + // // "type": 16, + // // "type_hex": "0000000000000010", + // // }, + // // }, + // // []any{ + // // map[string]any{ + // // "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + // // "type": 1, + // // "type_hex": "0000000000000001", + // // }, + // // map[string]any{ + // // "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", + // // "type": 1, + // // "type_hex": "0000000000000001", + // // }, + // // map[string]any{ + // // "currency": "XRP", + // // "type": 16, + // // "type_hex": "0000000000000010", + // // }, + // // }, + // // []any{ + // // map[string]any{ + // // "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + // // "type": 1, + // // "type_hex": "0000000000000001", + // // }, + // // map[string]any{ + // // "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", + // // "type": 1, + // // "type_hex": "0000000000000001", + // // }, + // // map[string]any{ + // // "currency": "XRP", + // // "type": 16, + // // "type_hex": "0000000000000010", + // // }, + // // }, + // // }, + // // "Memos": []any{ + // // map[string]any{ + // // "Memo": map[string]any{ + // // "MemoData": "04C4D46544659A2D58525043686174", + // // }, + // // }, + // // // }, + // // "LedgerEntryType": "RippleState", + // // "TransferFee": 30874, + // // "CloseResolution": 25, + // // "OwnerNode": "0000018446744073", + // // "Amendments": []string{ + // // "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", + // // "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", + // // }, + // // "EmailHash": "73734B611DDA23D3F5F62E20A173B78A", + // // "TakerPaysCurrency": "73734B611DDA23D3F5F62E20A173B78AB8406AC5", + // // "Digest": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", + // }, + // output: "11007212000714789A220008000024001ABED82A2380BF2C2019001ABED73400000184467440734173734B611DDA23D3F5F62E20A173B78A501573734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C64D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3744630440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C8114DD76483FACDEE26E60D8A586BB58D09F27045C46F9EA7D0F04C4D46544659A2D58525043686174E1F1011019011173734B611DDA23D3F5F62E20A173B78AB8406AC5011201F3B1997562FD742B54D4EBDEA1D6AEA3D4906B8F100000000000000000000000000000000000000000FF014B4E9C06F24296074F7BC48F92A97916C6DC5EA901DD39C650A96EDA48334E70CC4A85B8B2E8502CD3100000000000000000000000000000000000000000FF014B4E9C06F24296074F7BC48F92A97916C6DC5EA901DD39C650A96EDA48334E70CC4A85B8B2E8502CD31000000000000000000000000000000000000000000003134073734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", + // expectedErr: nil, + // }, + // { + // description: "zero issued currency amount", + // input: map[string]any{ + // "LowLimit": map[string]any{ + // "currency": "LUC", + // "issuer": "rsygE5ynt2iSasscfCCeqaGBGiFKMCAUu7", + // "value": "0", + // }, + // }, + // output: "6680000000000000000000000000000000000000004C5543000000000020A85019EA62B48F79EB67273B797EB916438FA4", + // expectedErr: nil, + // }, + // { + // description: "successfully serialized signed transaction 1", + // input: &transactions.OfferCreate{ + // BaseTx: transactions.BaseTx{ + // Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + // TransactionType: transactions.OfferCreateTx, + // Fee: 10, + // Flags: 524288, + // Sequence: 1752792, + // SigningPubKey: "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", + // TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", + // }, + // Expiration: 595640108, + // OfferSequence: 1752791, + // TakerGets: types.XRPCurrencyAmount(15000000000), + // TakerPays: types.IssuedCurrencyAmount{ + // Currency: "USD", + // Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + // Value: "7072.8", + // }, + // }, + // output: "120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3744630440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C8114DD76483FACDEE26E60D8A586BB58D09F27045C46", + // expectedErr: nil, + // }, + // { + // description: "successfully serialized signed transaction 2", + // input: &transactions.EscrowFinish{ + // BaseTx: transactions.BaseTx{ + // Account: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + // TransactionType: transactions.EscrowFinishTx, + // Fee: 10101, + // Flags: 2147483648, + // Sequence: 1, + // SigningPubKey: "0268D79CD579D077750740FA18A2370B7C2018B2714ECE70BA65C38D223E79BC9C", + // TxnSignature: "3045022100F06FB54049D6D50142E5CF2E2AC21946AF305A13E2A2D4BA881B36484DD01A540220311557EC8BEF536D729605A4CB4D4DC51B1E37C06C93434DD5B7651E1E2E28BF", + // Memos: []transactions.MemoWrapper{ + // { + // Memo: transactions.Memo{ + // MemoData: "04C4D46544659A2D58525043686174", + // }, + // }, + // }, + // }, + // OfferSequence: 11, + // Owner: "r9NpyVfLfUG8hatuCCHKzosyDtKnBdsEN3", + // }, + // output: "1200022280000000240000000120190000000B68400000000000277573210268D79CD579D077750740FA18A2370B7C2018B2714ECE70BA65C38D223E79BC9C74473045022100F06FB54049D6D50142E5CF2E2AC21946AF305A13E2A2D4BA881B36484DD01A540220311557EC8BEF536D729605A4CB4D4DC51B1E37C06C93434DD5B7651E1E2E28BF811452C7F01AD13B3CA9C1D133FA8F3482D2EF08FA7D82145A380FBD236B6A1CD14B939AD21101E5B6B6FFA2F9EA7D0F04C4D46544659A2D58525043686174E1F1", + // expectedErr: nil, + // }, { description: "successfully serialized signed transaction 3", - input: map[string]any{ - "Account": "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", - "Amount": "10000000", - "Destination": "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", - "Fee": "12", - "Flags": 0, - "LastLedgerSequence": 9902014, - "Memos": []any{ - map[string]any{ - "Memo": map[string]any{ - "MemoData": "7274312E312E31", - "MemoType": "636C69656E74", + input: &transactions.Payment{ + BaseTx: transactions.BaseTx{ + Account: "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", + TransactionType: transactions.PaymentTx, + Fee: 12, + Flags: 0, + Sequence: 842, + Memos: []transactions.MemoWrapper{ + { + Memo: transactions.Memo{ + MemoData: "7274312E312E31", + MemoType: "636C69656E74", + }, }, }, + LastLedgerSequence: 9902014, + SigningPubKey: "0379F17CFA0FFD7518181594BE69FE9A10471D6DE1F4055C6D2746AFD6CF89889E", + TxnSignature: "3045022100D55ED1953F860ADC1BC5CD993ABB927F48156ACA31C64737865F4F4FF6D015A80220630704D2BD09C8E99F26090C25F11B28F5D96A1350454402C2CED92B39FFDBAF", + }, + Amount: types.XRPCurrencyAmount(10000000), + Destination: "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", + SendMax: types.IssuedCurrencyAmount{ + Currency: "USD", + Issuer: "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", + Value: "0.6275558355", }, - "Paths": []any{ - []any{ - map[string]any{ - "account": "rPDXxSZcuVL3ZWoyU82bcde3zwvmShkRyF", - "type": 1, - "type_hex": "0000000000000001", + Paths: [][]transactions.PathStep{ + { + { + Account: "rPDXxSZcuVL3ZWoyU82bcde3zwvmShkRyF", }, - map[string]any{ - "currency": "XRP", - "type": 16, - "type_hex": "0000000000000010", + { + Currency: "XRP", }, }, - []any{ - map[string]any{ - "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - "type": 1, - "type_hex": "0000000000000001", + { + { + Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", }, - map[string]any{ - "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", - "type": 1, - "type_hex": "0000000000000001", + { + Account: "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", }, - map[string]any{ - "currency": "XRP", - "type": 16, - "type_hex": "0000000000000010", + { + Currency: "XRP", }, }, }, - "SendMax": map[string]any{ - "currency": "USD", - "issuer": "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", - "value": "0.6275558355", - }, - "Sequence": 842, - "SigningPubKey": "0379F17CFA0FFD7518181594BE69FE9A10471D6DE1F4055C6D2746AFD6CF89889E", - "TransactionType": "Payment", - "TxnSignature": "3045022100D55ED1953F860ADC1BC5CD993ABB927F48156ACA31C64737865F4F4FF6D015A80220630704D2BD09C8E99F26090C25F11B28F5D96A1350454402C2CED92B39FFDBAF", - "hash": "B521424226FC100A2A802FE20476A5F8426FD3F720176DC5CCCE0D75738CC208", }, expectedErr: nil, output: "1200002200000000240000034A201B009717BE61400000000098968068400000000000000C69D4564B964A845AC0000000000000000000000000555344000000000069D33B18D53385F8A3185516C2EDA5DEDB8AC5C673210379F17CFA0FFD7518181594BE69FE9A10471D6DE1F4055C6D2746AFD6CF89889E74473045022100D55ED1953F860ADC1BC5CD993ABB927F48156ACA31C64737865F4F4FF6D015A80220630704D2BD09C8E99F26090C25F11B28F5D96A1350454402C2CED92B39FFDBAF811469D33B18D53385F8A3185516C2EDA5DEDB8AC5C6831469D33B18D53385F8A3185516C2EDA5DEDB8AC5C6F9EA7C06636C69656E747D077274312E312E31E1F1011201F3B1997562FD742B54D4EBDEA1D6AEA3D4906B8F100000000000000000000000000000000000000000FF014B4E9C06F24296074F7BC48F92A97916C6DC5EA901DD39C650A96EDA48334E70CC4A85B8B2E8502CD310000000000000000000000000000000000000000000", }, - { - description: "serialize OwnerNode example - UInt64", - input: map[string]any{"OwnerNode": "18446744073"}, - output: "340000018446744073", - expectedErr: nil, - }, - { - description: "serialize LedgerEntryType example - UInt8", - input: map[string]any{"LedgerEntryType": "RippleState"}, - output: "110072", - expectedErr: nil, - }, - { - description: "serialize int example - UInt8", - input: map[string]any{"CloseResolution": 25}, - output: "011019", - expectedErr: nil, - }, - { - description: "serialize hash 128", - input: map[string]any{"EmailHash": "73734B611DDA23D3F5F62E20A173B78A"}, - output: "4173734B611DDA23D3F5F62E20A173B78A", - expectedErr: nil, - }, - { - description: "hash128 wrong length", - input: map[string]any{"EmailHash": "73734B611DDA23D3F5F62E20A173"}, - output: "", - expectedErr: &types.ErrInvalidHashLength{Expected: 16}, - }, - { - description: "serialize hash 160", - input: map[string]any{"TakerPaysCurrency": "73734B611DDA23D3F5F62E20A173B78AB8406AC5"}, - output: "011173734B611DDA23D3F5F62E20A173B78AB8406AC5", - expectedErr: nil, - }, - { - description: "hash160 wrong length", - input: map[string]any{"TakerPaysCurrency": "73734B611DDA23D3F5F62E20A173B789"}, - output: "", - expectedErr: &types.ErrInvalidHashLength{Expected: 20}, - }, - { - description: "serialize hash 256", - input: map[string]any{"Digest": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C"}, - output: "501573734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - expectedErr: nil, - }, - { - description: "hash256 wrong length", - input: map[string]any{"Digest": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F537"}, - output: "", - expectedErr: &types.ErrInvalidHashLength{Expected: 32}, - }, - { - description: "serialize Vector256 successfully,", - input: map[string]any{"Amendments": []string{"73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C"}}, - output: "03134073734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - expectedErr: nil, - }, - { - description: "invalid input for Vector256 - not a string array", - input: map[string]any{"Amendments": []int{1, 2, 3}}, - output: "", - expectedErr: &types.ErrInvalidVector256Type{Got: "[]int"}, - }, - { - description: "invalid input for Vector256 - wrong hash length", - input: map[string]any{"Amendments": []string{"73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C56342689", "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06"}}, - output: "", - expectedErr: &types.ErrInvalidHashLength{Expected: types.HashLengthBytes}, - }, - { - description: "serialize STObject correctly", - input: map[string]any{ - "Memo": map[string]any{ - "MemoType": "04C4D46544659A2D58525043686174", - }, - }, - output: "EA7C0F04C4D46544659A2D58525043686174E1", - expectedErr: nil, - }, - { - description: "invalid pathset", - input: map[string]any{"Paths": []any{ - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", - }, - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", - }, - }, - }, - output: "", - expectedErr: types.ErrInvalidPathSet, - }, + // { + // description: "serialize OwnerNode example - UInt64", + // input: map[string]any{"OwnerNode": "18446744073"}, + // output: "340000018446744073", + // expectedErr: nil, + // }, + // { + // description: "serialize LedgerEntryType example - UInt8", + // input: map[string]any{"LedgerEntryType": "RippleState"}, + // output: "110072", + // expectedErr: nil, + // }, + // { + // description: "serialize int example - UInt8", + // input: map[string]any{"CloseResolution": 25}, + // output: "011019", + // expectedErr: nil, + // }, + // { + // description: "serialize hash 128", + // input: map[string]any{"EmailHash": "73734B611DDA23D3F5F62E20A173B78A"}, + // output: "4173734B611DDA23D3F5F62E20A173B78A", + // expectedErr: nil, + // }, + // { + // description: "hash128 wrong length", + // input: map[string]any{"EmailHash": "73734B611DDA23D3F5F62E20A173"}, + // output: "", + // expectedErr: &types.ErrInvalidHashLength{Expected: 16}, + // }, + // { + // description: "serialize hash 160", + // input: map[string]any{"TakerPaysCurrency": "73734B611DDA23D3F5F62E20A173B78AB8406AC5"}, + // output: "011173734B611DDA23D3F5F62E20A173B78AB8406AC5", + // expectedErr: nil, + // }, + // { + // description: "hash160 wrong length", + // input: map[string]any{"TakerPaysCurrency": "73734B611DDA23D3F5F62E20A173B789"}, + // output: "", + // expectedErr: &types.ErrInvalidHashLength{Expected: 20}, + // }, + // { + // description: "serialize hash 256", + // input: map[string]any{"Digest": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C"}, + // output: "501573734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", + // expectedErr: nil, + // }, + // { + // description: "hash256 wrong length", + // input: map[string]any{"Digest": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F537"}, + // output: "", + // expectedErr: &types.ErrInvalidHashLength{Expected: 32}, + // }, + // { + // description: "serialize Vector256 successfully,", + // input: map[string]any{"Amendments": []string{"73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C"}}, + // output: "03134073734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", + // expectedErr: nil, + // }, + // { + // description: "invalid input for Vector256 - not a string array", + // input: map[string]any{"Amendments": []int{1, 2, 3}}, + // output: "", + // expectedErr: &types.ErrInvalidVector256Type{Got: "[]int"}, + // }, + // { + // description: "invalid input for Vector256 - wrong hash length", + // input: map[string]any{"Amendments": []string{"73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C56342689", "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06"}}, + // output: "", + // expectedErr: &types.ErrInvalidHashLength{Expected: types.HashLengthBytes}, + // }, + // { + // description: "serialize STObject correctly", + // input: &transactions.OfferCreate{ + // BaseTx: transactions.BaseTx{ + // Memos: []transactions.MemoWrapper{ + // { + // Memo: transactions.Memo{ + // MemoType: "04C4D46544659A2D58525043686174", + // }, + // }, + // }, + // }, + // }, + // output: "F9EA7C0F04C4D46544659A2D58525043686174E1F1", + // expectedErr: nil, + // }, } for _, tc := range tt { @@ -446,205 +454,205 @@ func TestDecode(t *testing.T) { } -func TestEncodeForMultisigning(t *testing.T) { - tt := []struct { - description string - json map[string]any - accountID string - output string - expectedErr error - }{ - { - description: "serialize tx1 for signing correctly", - json: map[string]any{ - "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - "Expiration": 595640108, - "Fee": "10", - "Flags": 524288, - "OfferSequence": 1752791, - "Sequence": 1752792, - "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", - "TakerGets": "15000000000", - "TakerPays": map[string]any{ - "currency": "USD", - "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - "value": "7072.8", - }, - "TransactionType": "OfferCreate", - "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", - "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - }, - accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", - expectedErr: nil, - }, - { - description: "SigningPubKey is not present", - json: map[string]any{ - "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - "Expiration": 595640108, - "Fee": "10", - "Flags": 524288, - "OfferSequence": 1752791, - "Sequence": 1752792, - "TakerGets": "15000000000", - "TakerPays": map[string]any{ - "currency": "USD", - "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - "value": "7072.8", - }, - "TransactionType": "OfferCreate", - "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", - "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - }, - accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", - expectedErr: nil, - }, - { - description: "SigningPubKey empty string", - json: map[string]any{ - "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - "Expiration": 595640108, - "Fee": "10", - "Flags": 524288, - "OfferSequence": 1752791, - "Sequence": 1752792, - "SigningPubKey": "", - "TakerGets": "15000000000", - "TakerPays": map[string]any{ - "currency": "USD", - "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - "value": "7072.8", - }, - "TransactionType": "OfferCreate", - "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", - "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - }, - accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", - expectedErr: nil, - }, - } +// func TestEncodeForMultisigning(t *testing.T) { +// tt := []struct { +// description string +// json map[string]any +// accountID string +// output string +// expectedErr error +// }{ +// { +// description: "serialize tx1 for signing correctly", +// json: map[string]any{ +// "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", +// "Expiration": 595640108, +// "Fee": "10", +// "Flags": 524288, +// "OfferSequence": 1752791, +// "Sequence": 1752792, +// "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", +// "TakerGets": "15000000000", +// "TakerPays": map[string]any{ +// "currency": "USD", +// "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", +// "value": "7072.8", +// }, +// "TransactionType": "OfferCreate", +// "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", +// "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", +// }, +// accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", +// output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", +// expectedErr: nil, +// }, +// { +// description: "SigningPubKey is not present", +// json: map[string]any{ +// "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", +// "Expiration": 595640108, +// "Fee": "10", +// "Flags": 524288, +// "OfferSequence": 1752791, +// "Sequence": 1752792, +// "TakerGets": "15000000000", +// "TakerPays": map[string]any{ +// "currency": "USD", +// "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", +// "value": "7072.8", +// }, +// "TransactionType": "OfferCreate", +// "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", +// "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", +// }, +// accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", +// output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", +// expectedErr: nil, +// }, +// { +// description: "SigningPubKey empty string", +// json: map[string]any{ +// "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", +// "Expiration": 595640108, +// "Fee": "10", +// "Flags": 524288, +// "OfferSequence": 1752791, +// "Sequence": 1752792, +// "SigningPubKey": "", +// "TakerGets": "15000000000", +// "TakerPays": map[string]any{ +// "currency": "USD", +// "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", +// "value": "7072.8", +// }, +// "TransactionType": "OfferCreate", +// "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", +// "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", +// }, +// accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", +// output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", +// expectedErr: nil, +// }, +// } - for _, tc := range tt { - t.Run(tc.description, func(t *testing.T) { - got, err := EncodeForMultisigning(tc.json, tc.accountID) +// for _, tc := range tt { +// t.Run(tc.description, func(t *testing.T) { +// got, err := EncodeForMultisigning(tc.json, tc.accountID) - if tc.expectedErr != nil { - require.EqualError(t, err, tc.expectedErr.Error()) - require.Empty(t, got) - } else { - require.NoError(t, err) - require.Equal(t, tc.output, got) - } - }) - } -} +// if tc.expectedErr != nil { +// require.EqualError(t, err, tc.expectedErr.Error()) +// require.Empty(t, got) +// } else { +// require.NoError(t, err) +// require.Equal(t, tc.output, got) +// } +// }) +// } +// } -func TestEncodeForSigningClaim(t *testing.T) { +// func TestEncodeForSigningClaim(t *testing.T) { - tt := []struct { - description string - input map[string]any - output string - expectedErr error - }{ - { - description: "successfully encode claim", - input: map[string]any{ - "Channel": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1", - "Amount": "1000", - }, - output: "434C4D0043904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB100000000000003E8", - expectedErr: nil, - }, - { - description: "fail to encode claim - no channel", - input: map[string]any{ - "Amount": "1000", - }, - output: "", - expectedErr: ErrSigningClaimFieldNotFound, - }, - { - description: "fail to encode claim - no amount", - input: map[string]any{ - "Channel": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1", - }, - output: "", - expectedErr: ErrSigningClaimFieldNotFound, - }, - } +// tt := []struct { +// description string +// input map[string]any +// output string +// expectedErr error +// }{ +// { +// description: "successfully encode claim", +// input: map[string]any{ +// "Channel": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1", +// "Amount": "1000", +// }, +// output: "434C4D0043904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB100000000000003E8", +// expectedErr: nil, +// }, +// { +// description: "fail to encode claim - no channel", +// input: map[string]any{ +// "Amount": "1000", +// }, +// output: "", +// expectedErr: ErrSigningClaimFieldNotFound, +// }, +// { +// description: "fail to encode claim - no amount", +// input: map[string]any{ +// "Channel": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1", +// }, +// output: "", +// expectedErr: ErrSigningClaimFieldNotFound, +// }, +// } - for _, tc := range tt { - t.Run(tc.description, func(t *testing.T) { - got, err := EncodeForSigningClaim(tc.input) +// for _, tc := range tt { +// t.Run(tc.description, func(t *testing.T) { +// got, err := EncodeForSigningClaim(tc.input) - if tc.expectedErr != nil { - require.EqualError(t, err, tc.expectedErr.Error()) - require.Empty(t, got) - } else { - require.NoError(t, err) - require.Equal(t, tc.output, got) - } - }) - } -} +// if tc.expectedErr != nil { +// require.EqualError(t, err, tc.expectedErr.Error()) +// require.Empty(t, got) +// } else { +// require.NoError(t, err) +// require.Equal(t, tc.output, got) +// } +// }) +// } +// } -func TestEncodeForSigning(t *testing.T) { - tt := []struct { - description string - input map[string]any - output string - expectedErr error - }{ - { - description: "serialize STObject for signing correctly", - input: map[string]any{ - "Memo": map[string]any{ - "MemoType": "04C4D46544659A2D58525043686174", - }, - }, - output: "53545800EA7C0F04C4D46544659A2D58525043686174E1", - expectedErr: nil, - }, - { - description: "serialize tx1 for signing correctly", - input: map[string]any{ - "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - "Expiration": 595640108, - "Fee": "10", - "Flags": 524288, - "OfferSequence": 1752791, - "Sequence": 1752792, - "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", - "TakerGets": "15000000000", - "TakerPays": map[string]any{ - "currency": "USD", - "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - "value": "7072.8", - }, - "TransactionType": "OfferCreate", - "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", - "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - }, - output: "53545800120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE38114DD76483FACDEE26E60D8A586BB58D09F27045C46", - expectedErr: nil, - }, - } +// func TestEncodeForSigning(t *testing.T) { +// tt := []struct { +// description string +// input map[string]any +// output string +// expectedErr error +// }{ +// { +// description: "serialize STObject for signing correctly", +// input: map[string]any{ +// "Memo": map[string]any{ +// "MemoType": "04C4D46544659A2D58525043686174", +// }, +// }, +// output: "53545800EA7C0F04C4D46544659A2D58525043686174E1", +// expectedErr: nil, +// }, +// { +// description: "serialize tx1 for signing correctly", +// input: map[string]any{ +// "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", +// "Expiration": 595640108, +// "Fee": "10", +// "Flags": 524288, +// "OfferSequence": 1752791, +// "Sequence": 1752792, +// "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", +// "TakerGets": "15000000000", +// "TakerPays": map[string]any{ +// "currency": "USD", +// "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", +// "value": "7072.8", +// }, +// "TransactionType": "OfferCreate", +// "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", +// "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", +// }, +// output: "53545800120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE38114DD76483FACDEE26E60D8A586BB58D09F27045C46", +// expectedErr: nil, +// }, +// } - for _, tc := range tt { - t.Run(tc.description, func(t *testing.T) { - got, err := EncodeForSigning(tc.input) +// for _, tc := range tt { +// t.Run(tc.description, func(t *testing.T) { +// got, err := EncodeForSigning(tc.input) - if tc.expectedErr != nil { - require.EqualError(t, err, tc.expectedErr.Error()) - require.Empty(t, got) - } else { - require.NoError(t, err) - require.Equal(t, tc.output, got) - } - }) - } -} +// if tc.expectedErr != nil { +// require.EqualError(t, err, tc.expectedErr.Error()) +// require.Empty(t, got) +// } else { +// require.NoError(t, err) +// require.Equal(t, tc.output, got) +// } +// }) +// } +// } diff --git a/binary-codec/st_array_test.go b/binary-codec/st_array_test.go index 6b783157..6da37c70 100644 --- a/binary-codec/st_array_test.go +++ b/binary-codec/st_array_test.go @@ -1,316 +1,316 @@ package binarycodec -import ( - "testing" +// import ( +// "testing" - "github.com/stretchr/testify/require" -) +// "github.com/stretchr/testify/require" +// ) -func TestSTArrayFromJson(t *testing.T) { - tt := []struct { - description string - input map[string]any - output string - expectedErr error - }{ - { - description: "nested stobject test", - input: map[string]any{ - "AffectedNodes": []any{ - map[string]any{ - "DeletedNode": map[string]any{ - "FinalFields": map[string]any{ - "ExchangeRate": "4a0745621d069432", - "Flags": 0, - "RootIndex": "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", - "TakerGetsCurrency": "0000000000000000000000000000000000000000", - "TakerGetsIssuer": "0000000000000000000000000000000000000000", - "TakerPaysCurrency": "0000000000000000000000004254430000000000", - "TakerPaysIssuer": "06A148131B436B2561C85967685B098E050EED4E", - }, - "LedgerEntryType": "DirectoryNode", - "LedgerIndex": "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", - }, - }, - map[string]any{ - "ModifiedNode": map[string]any{ - "FinalFields": map[string]any{ - "Flags": 0, - "Owner": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", - "RootIndex": "5ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC", - }, - "LedgerEntryType": "DirectoryNode", - "LedgerIndex": "5ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC", - }, - }, - map[string]any{ - "DeletedNode": map[string]any{ - "FinalFields": map[string]any{ - "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", - "BookDirectory": "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", - "BookNode": "0", - "Flags": 131072, - "OwnerNode": "0", - "PreviousTxnID": "B21E9DC8DCB75AD12C4ACF4C72E6E822244CF6CFFD7BD738ACEED1264374B687", - "PreviousTxnLgrSeq": 82010985, - "Sequence": 59434311, - "TakerGets": "1166610661", - "TakerPays": map[string]any{ - "currency": "BTC", - "issuer": "rchGBxcD1A1C2tdxF6papQYZ8kjRKMYcL", - "value": "0.023876", - }, - }, - "LedgerEntryType": "Offer", - "LedgerIndex": "C171AA6003AE67B218E5EFFEF3E49CB5A4FE5A06D82C1F7EEF322B036EF76CE7", - }, - }, - map[string]any{ - "ModifiedNode": map[string]any{ - "FinalFields": map[string]any{ - "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", - "Balance": "3310960263", - "Flags": 0, - "MessageKey": "020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144", - "OwnerCount": 8, - "Sequence": 59434319, - }, - "LedgerEntryType": "AccountRoot", - "LedgerIndex": "F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1", - "PreviousFields": map[string]any{ - "Balance": "3310960413", - "OwnerCount": 9, - "Sequence": 59434318, - }, - "PreviousTxnID": "DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE683", - "PreviousTxnLgrSeq": 82011654, - }, - }, - }, - "TransactionIndex": 31, - "TransactionResult": "tesSUCCESS", - }, - output: "201C0000001FF8E411006456036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432E72200000000364A0745621D06943258036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D06943201110000000000000000000000004254430000000000021106A148131B436B2561C85967685B098E050EED4E0311000000000000000000000000000000000000000004110000000000000000000000000000000000000000E1E1E5110064565ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFCE72200000000585ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC821407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1E411006F56C171AA6003AE67B218E5EFFEF3E49CB5A4FE5A06D82C1F7EEF322B036EF76CE7E7220002000024038AE5472504E3636933000000000000000034000000000000000055B21E9DC8DCB75AD12C4ACF4C72E6E822244CF6CFFD7BD738ACEED1264374B6875010036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D06943264D4087B8271DDA000000000000000000000000000425443000000000006A148131B436B2561C85967685B098E050EED4E6540000000458910E5811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1E51100612504E3660655DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE68356F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1E624038AE54E2D000000096240000000C5593F1DE1E7220000000024038AE54F2D000000086240000000C5593E877221020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1F1031000", - expectedErr: nil, - }, - { - description: "large starray test", - input: map[string]any{ - "AffectedNodes": []any{ - map[string]any{ - "ModifiedNode": map[string]any{ - "LedgerEntryType": "NFTokenPage", - "LedgerIndex": "1D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291", - "PreviousFields": map[string]any{ - "NFTokens": []any{ - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - map[string]any{ - "Signer": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - map[string]any{ - "Majority": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - map[string]any{ - "DisabledValidator": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - }, - }, - "PreviousTxnID": "0D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF", - "PreviousTxnLgrSeq": 81744044, - }, - "DeletedNode": map[string]any{ - "LedgerEntryType": "NFTokenPage", - "LedgerIndex": "1D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291", - "PreviousFields": map[string]any{ - "NFTokens": []any{ - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - }, - }, - "PreviousTxnID": "0D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF", - "PreviousTxnLgrSeq": 81744044, - }, - }, - map[string]any{ - "ModifiedNode": map[string]any{ - "LedgerEntryType": "NFTokenPage", - "LedgerIndex": "1D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291", - "PreviousFields": map[string]any{ - "NFTokens": []any{ - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA", - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - }, - }, - "PreviousTxnID": "0D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF", - "PreviousTxnLgrSeq": 81744044, - }, - }, - }, - "TransactionIndex": 55, - "TransactionResult": "tesSUCCESS", - }, - output: "201C00000037F8E41100502504DF50AC550D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF561D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291E6FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1E1E1E51100502504DF50AC550D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF561D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291E6FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1E0105A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1E0125A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1E0135A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1E1E1E51100502504DF50AC550D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF561D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291E6FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1E1E1F1031000", - expectedErr: nil, - }, - } +// func TestSTArrayFromJson(t *testing.T) { +// tt := []struct { +// description string +// input map[string]any +// output string +// expectedErr error +// }{ +// { +// description: "nested stobject test", +// input: map[string]any{ +// "AffectedNodes": []any{ +// map[string]any{ +// "DeletedNode": map[string]any{ +// "FinalFields": map[string]any{ +// "ExchangeRate": "4a0745621d069432", +// "Flags": 0, +// "RootIndex": "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", +// "TakerGetsCurrency": "0000000000000000000000000000000000000000", +// "TakerGetsIssuer": "0000000000000000000000000000000000000000", +// "TakerPaysCurrency": "0000000000000000000000004254430000000000", +// "TakerPaysIssuer": "06A148131B436B2561C85967685B098E050EED4E", +// }, +// "LedgerEntryType": "DirectoryNode", +// "LedgerIndex": "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", +// }, +// }, +// map[string]any{ +// "ModifiedNode": map[string]any{ +// "FinalFields": map[string]any{ +// "Flags": 0, +// "Owner": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", +// "RootIndex": "5ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC", +// }, +// "LedgerEntryType": "DirectoryNode", +// "LedgerIndex": "5ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC", +// }, +// }, +// map[string]any{ +// "DeletedNode": map[string]any{ +// "FinalFields": map[string]any{ +// "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", +// "BookDirectory": "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", +// "BookNode": "0", +// "Flags": 131072, +// "OwnerNode": "0", +// "PreviousTxnID": "B21E9DC8DCB75AD12C4ACF4C72E6E822244CF6CFFD7BD738ACEED1264374B687", +// "PreviousTxnLgrSeq": 82010985, +// "Sequence": 59434311, +// "TakerGets": "1166610661", +// "TakerPays": map[string]any{ +// "currency": "BTC", +// "issuer": "rchGBxcD1A1C2tdxF6papQYZ8kjRKMYcL", +// "value": "0.023876", +// }, +// }, +// "LedgerEntryType": "Offer", +// "LedgerIndex": "C171AA6003AE67B218E5EFFEF3E49CB5A4FE5A06D82C1F7EEF322B036EF76CE7", +// }, +// }, +// map[string]any{ +// "ModifiedNode": map[string]any{ +// "FinalFields": map[string]any{ +// "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", +// "Balance": "3310960263", +// "Flags": 0, +// "MessageKey": "020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144", +// "OwnerCount": 8, +// "Sequence": 59434319, +// }, +// "LedgerEntryType": "AccountRoot", +// "LedgerIndex": "F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1", +// "PreviousFields": map[string]any{ +// "Balance": "3310960413", +// "OwnerCount": 9, +// "Sequence": 59434318, +// }, +// "PreviousTxnID": "DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE683", +// "PreviousTxnLgrSeq": 82011654, +// }, +// }, +// }, +// "TransactionIndex": 31, +// "TransactionResult": "tesSUCCESS", +// }, +// output: "201C0000001FF8E411006456036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432E72200000000364A0745621D06943258036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D06943201110000000000000000000000004254430000000000021106A148131B436B2561C85967685B098E050EED4E0311000000000000000000000000000000000000000004110000000000000000000000000000000000000000E1E1E5110064565ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFCE72200000000585ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC821407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1E411006F56C171AA6003AE67B218E5EFFEF3E49CB5A4FE5A06D82C1F7EEF322B036EF76CE7E7220002000024038AE5472504E3636933000000000000000034000000000000000055B21E9DC8DCB75AD12C4ACF4C72E6E822244CF6CFFD7BD738ACEED1264374B6875010036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D06943264D4087B8271DDA000000000000000000000000000425443000000000006A148131B436B2561C85967685B098E050EED4E6540000000458910E5811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1E51100612504E3660655DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE68356F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1E624038AE54E2D000000096240000000C5593F1DE1E7220000000024038AE54F2D000000086240000000C5593E877221020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1F1031000", +// expectedErr: nil, +// }, +// { +// description: "large starray test", +// input: map[string]any{ +// "AffectedNodes": []any{ +// map[string]any{ +// "ModifiedNode": map[string]any{ +// "LedgerEntryType": "NFTokenPage", +// "LedgerIndex": "1D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291", +// "PreviousFields": map[string]any{ +// "NFTokens": []any{ +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// map[string]any{ +// "Signer": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// map[string]any{ +// "Majority": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// map[string]any{ +// "DisabledValidator": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// }, +// }, +// "PreviousTxnID": "0D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF", +// "PreviousTxnLgrSeq": 81744044, +// }, +// "DeletedNode": map[string]any{ +// "LedgerEntryType": "NFTokenPage", +// "LedgerIndex": "1D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291", +// "PreviousFields": map[string]any{ +// "NFTokens": []any{ +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// }, +// }, +// "PreviousTxnID": "0D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF", +// "PreviousTxnLgrSeq": 81744044, +// }, +// }, +// map[string]any{ +// "ModifiedNode": map[string]any{ +// "LedgerEntryType": "NFTokenPage", +// "LedgerIndex": "1D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291", +// "PreviousFields": map[string]any{ +// "NFTokens": []any{ +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA", +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// }, +// }, +// "PreviousTxnID": "0D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF", +// "PreviousTxnLgrSeq": 81744044, +// }, +// }, +// }, +// "TransactionIndex": 55, +// "TransactionResult": "tesSUCCESS", +// }, +// output: "201C00000037F8E41100502504DF50AC550D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF561D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291E6FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1E1E1E51100502504DF50AC550D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF561D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291E6FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1E0105A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1E0125A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1E0135A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1E1E1E51100502504DF50AC550D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF561D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291E6FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1E1E1F1031000", +// expectedErr: nil, +// }, +// } - for _, tc := range tt { - t.Run(tc.description, func(t *testing.T) { - got, err := Encode(tc.input) +// for _, tc := range tt { +// t.Run(tc.description, func(t *testing.T) { +// got, err := Encode(tc.input) - if tc.expectedErr != nil { - require.EqualError(t, err, tc.expectedErr.Error()) - require.Empty(t, got) - } else { - require.NoError(t, err) - require.Equal(t, tc.output, got) - } - }) - } +// if tc.expectedErr != nil { +// require.EqualError(t, err, tc.expectedErr.Error()) +// require.Empty(t, got) +// } else { +// require.NoError(t, err) +// require.Equal(t, tc.output, got) +// } +// }) +// } -} +// } -func TestSTArrayToJson(t *testing.T) { - tt := []struct { - description string - input string - output map[string]any - expectedErr error - }{ - { - description: "large starray", - input: "FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9E1E010754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1", - output: map[string]any{ - "NFTokens": []any{ - map[string]any{ - "NFToken": map[string]any{ - "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", - }, - }, - map[string]any{ - "Signer": map[string]any{ - "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", - }, - }, - }, - }, - expectedErr: nil, - }, - { - description: "simple starray", - input: "F9EA364A0745621D0694327D0F04C4D46544659A2D58525043686174E1E9364A0745621D0694327D0F04C4D46544659A2D58525043686174E1F1", - output: map[string]any{ - "Memos": []any{ - map[string]any{ - "Memo": map[string]any{ - "MemoData": "04C4D46544659A2D58525043686174", - "ExchangeRate": "4A0745621D069432", - }, - }, - map[string]any{ - "TemplateEntry": map[string]any{ - "MemoData": "04C4D46544659A2D58525043686174", - "ExchangeRate": "4A0745621D069432", - }, - }, - }, - }, - }, - { - description: "smaller stobject test", - input: "E51100612504E3660655DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE68356F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1E624038AE54E2D000000096240000000C5593F1DE1E7220000000024038AE54F2D000000086240000000C5593E877221020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1", - output: map[string]any{ - "ModifiedNode": map[string]any{ - "FinalFields": map[string]any{ - "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", - "Balance": "3310960263", - "Flags": 0, - "MessageKey": "020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144", - "OwnerCount": 8, - "Sequence": 59434319, - }, - "LedgerEntryType": "AccountRoot", - "LedgerIndex": "F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1", - "PreviousFields": map[string]any{ - "Balance": "3310960413", - "OwnerCount": 9, - "Sequence": 59434318, - }, - "PreviousTxnID": "DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE683", - "PreviousTxnLgrSeq": 82011654, - }, - }, - }, - } +// func TestSTArrayToJson(t *testing.T) { +// tt := []struct { +// description string +// input string +// output map[string]any +// expectedErr error +// }{ +// { +// description: "large starray", +// input: "FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9E1E010754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1", +// output: map[string]any{ +// "NFTokens": []any{ +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", +// }, +// }, +// map[string]any{ +// "Signer": map[string]any{ +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// }, +// }, +// expectedErr: nil, +// }, +// { +// description: "simple starray", +// input: "F9EA364A0745621D0694327D0F04C4D46544659A2D58525043686174E1E9364A0745621D0694327D0F04C4D46544659A2D58525043686174E1F1", +// output: map[string]any{ +// "Memos": []any{ +// map[string]any{ +// "Memo": map[string]any{ +// "MemoData": "04C4D46544659A2D58525043686174", +// "ExchangeRate": "4A0745621D069432", +// }, +// }, +// map[string]any{ +// "TemplateEntry": map[string]any{ +// "MemoData": "04C4D46544659A2D58525043686174", +// "ExchangeRate": "4A0745621D069432", +// }, +// }, +// }, +// }, +// }, +// { +// description: "smaller stobject test", +// input: "E51100612504E3660655DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE68356F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1E624038AE54E2D000000096240000000C5593F1DE1E7220000000024038AE54F2D000000086240000000C5593E877221020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1", +// output: map[string]any{ +// "ModifiedNode": map[string]any{ +// "FinalFields": map[string]any{ +// "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", +// "Balance": "3310960263", +// "Flags": 0, +// "MessageKey": "020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144", +// "OwnerCount": 8, +// "Sequence": 59434319, +// }, +// "LedgerEntryType": "AccountRoot", +// "LedgerIndex": "F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1", +// "PreviousFields": map[string]any{ +// "Balance": "3310960413", +// "OwnerCount": 9, +// "Sequence": 59434318, +// }, +// "PreviousTxnID": "DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE683", +// "PreviousTxnLgrSeq": 82011654, +// }, +// }, +// }, +// } - for _, tc := range tt { - t.Run(tc.description, func(t *testing.T) { - act, err := Decode(tc.input) - if tc.expectedErr != nil { - require.Error(t, err, tc.expectedErr.Error()) - require.Nil(t, act) - } else { - require.NoError(t, err) - require.EqualValues(t, tc.output, act) - } - }) - } -} +// for _, tc := range tt { +// t.Run(tc.description, func(t *testing.T) { +// act, err := Decode(tc.input) +// if tc.expectedErr != nil { +// require.Error(t, err, tc.expectedErr.Error()) +// require.Nil(t, act) +// } else { +// require.NoError(t, err) +// require.EqualValues(t, tc.output, act) +// } +// }) +// } +// } diff --git a/binary-codec/types/account_id.go b/binary-codec/types/account_id.go index 09314432..bac19f47 100644 --- a/binary-codec/types/account_id.go +++ b/binary-codec/types/account_id.go @@ -3,6 +3,7 @@ package types import ( addresscodec "github.com/CreatureDev/xrpl-go/address-codec" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) // AccountID struct represents an account ID. @@ -17,7 +18,7 @@ type AccountID struct{} // AccountIDs that appear as children of special fields (Amount issuer and PathSet account) are not length-prefixed. // So in Amount and PathSet fields, don't use the length indicator 0x14. func (a *AccountID) FromJson(value any) ([]byte, error) { - _, accountID, err := addresscodec.DecodeClassicAddressToAccountID(value.(string)) + _, accountID, err := addresscodec.DecodeClassicAddressToAccountID(string(value.(types.Address))) if err != nil { return nil, err diff --git a/binary-codec/types/amount.go b/binary-codec/types/amount.go index d40bef67..703945f9 100644 --- a/binary-codec/types/amount.go +++ b/binary-codec/types/amount.go @@ -13,6 +13,7 @@ import ( addresscodec "github.com/CreatureDev/xrpl-go/address-codec" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/model/transactions/types" bigdecimal "github.com/CreatureDev/xrpl-go/pkg/big-decimal" ) @@ -43,12 +44,12 @@ var ( // InvalidAmountError is a custom error type for invalid amounts. type InvalidAmountError struct { - Amount string + Amount types.XRPCurrencyAmount } // Error method for InvalidAmountError returns a formatted error string. func (e *InvalidAmountError) Error() string { - return fmt.Sprintf("value '%s' is an invalid amount", e.Amount) + return fmt.Sprintf("value '%v' is an invalid amount", e.Amount) } // OutOfRangeError is a custom error type for out-of-range values. @@ -77,11 +78,11 @@ type Amount struct{} // FromJson serializes an issued currency amount to its bytes representation from JSON. func (a *Amount) FromJson(value any) ([]byte, error) { - switch value := value.(type) { - case string: - return serializeXrpAmount(value) - case map[string]any: - return serializeIssuedCurrencyAmount(value["value"].(string), value["currency"].(string), value["issuer"].(string)) + switch v := value.(type) { + case types.XRPCurrencyAmount: + return serializeXrpAmount(v) + case types.IssuedCurrencyAmount: + return serializeIssuedCurrencyAmount(v) default: return nil, errors.New("invalid amount type") } @@ -190,21 +191,10 @@ func deserializeIssuer(data []byte) (string, error) { // verifyXrpValue validates the format of an XRP amount value. // XRP values should not contain a decimal point because they are represented as integers as drops. -func verifyXrpValue(value string) error { - - r := regexp.MustCompile(`\d+`) // regex to match only digits - m := r.FindAllString(value, -1) - - if len(m) != 1 { - return ErrInvalidXRPValue - } +func verifyXrpValue(value types.XRPCurrencyAmount) error { decimal := new(big.Float) - decimal, ok := decimal.SetString(value) // bigFloat for precision - - if !ok { - return errors.New("failed to convert string to big.Float") - } + decimal = decimal.SetUint64(uint64(value)) // bigFloat for precision if decimal.Sign() == 0 { return nil @@ -246,19 +236,13 @@ func verifyIOUValue(value string) error { } // serializeXrpAmount serializes an XRP amount value. -func serializeXrpAmount(value string) ([]byte, error) { +func serializeXrpAmount(value types.XRPCurrencyAmount) ([]byte, error) { if verifyXrpValue(value) != nil { return nil, verifyXrpValue(value) } - val, err := strconv.ParseUint(value, 10, 64) - - if err != nil { - return nil, err - } - - valWithPosBit := val | PosSignBitMask + valWithPosBit := value | PosSignBitMask valBytes := make([]byte, NativeAmountByteLength) binary.BigEndian.PutUint64(valBytes, uint64(valWithPosBit)) @@ -275,7 +259,7 @@ func serializeXrpAmount(value string) ([]byte, error) { // over-rounding in the least significant digits. // SerializeIssuedCurrencyValue serializes the value field of an issued currency amount to its bytes representation. -func SerializeIssuedCurrencyValue(value string) ([]byte, error) { +func serializeIssuedCurrencyValue(value string) ([]byte, error) { if verifyIOUValue(value) != nil { return nil, verifyIOUValue(value) @@ -400,26 +384,27 @@ func serializeIssuedCurrencyCodeChars(currency string) ([]byte, error) { // from value, currency code, and issuer address in string form (e.g. "USD", "r123456789"). // The currency code can be 3 allowed string characters, or 20 bytes of hex in standard currency format (e.g. with "00" prefix) // or non-standard currency format (e.g. without "00" prefix) -func serializeIssuedCurrencyAmount(value, currency, issuer string) ([]byte, error) { +func serializeIssuedCurrencyAmount(value types.IssuedCurrencyAmount) ([]byte, error) { var valBytes []byte var err error - if value == "0" { + if value.Value == "0" { valBytes = make([]byte, 8) binary.BigEndian.PutUint64(valBytes, uint64(ZeroCurrencyAmountHex)) } else { - valBytes, err = SerializeIssuedCurrencyValue(value) // serialize the value + valBytes, err = serializeIssuedCurrencyValue(value.Value) // serialize the value } + // valBytes, err := serializeIssuedCurrencyValue(value.Value) // serialize the value if err != nil { return nil, err } - currencyBytes, err := serializeIssuedCurrencyCode(currency) // serialize the currency code + currencyBytes, err := serializeIssuedCurrencyCode(value.Currency) // serialize the currency code if err != nil { return nil, err } - _, issuerBytes, err := addresscodec.DecodeClassicAddressToAccountID(issuer) // decode the issuer address + _, issuerBytes, err := addresscodec.DecodeClassicAddressToAccountID(string(value.Issuer)) // decode the issuer address if err != nil { return nil, err } diff --git a/binary-codec/types/amount_test.go b/binary-codec/types/amount_test.go index 9ff16544..263206ed 100644 --- a/binary-codec/types/amount_test.go +++ b/binary-codec/types/amount_test.go @@ -3,37 +3,38 @@ package types import ( "testing" - "github.com/stretchr/testify/require" + "github.com/CreatureDev/xrpl-go/model/transactions/types" bigdecimal "github.com/CreatureDev/xrpl-go/pkg/big-decimal" + "github.com/stretchr/testify/require" ) func TestVerifyXrpValue(t *testing.T) { tests := []struct { name string - input string + input types.XRPCurrencyAmount expErr error }{ - { - name: "invalid xrp value", - input: "1.0", - expErr: ErrInvalidXRPValue, - }, - { - name: "invalid xrp value - out of range", - input: "0.000000007", - expErr: ErrInvalidXRPValue, - }, + // { + // name: "invalid xrp value", + // input: 1.0, + // expErr: ErrInvalidXRPValue, + // }, + // { + // name: "invalid xrp value - out of range", + // input: 0.000000007, + // expErr: ErrInvalidXRPValue, + // }, { name: "valid xrp value - no decimal", - input: "125000708", + input: 125000708, expErr: nil, }, - { - name: "valid xrp value - no decimal - negative value", - input: "-125000708", - expErr: &InvalidAmountError{Amount: "-125000708"}, - }, + // { + // name: "invalid xrp value - no decimal - negative value", + // input: -125000708, + // expErr: &InvalidAmountError{Amount: "-125000708"}, + // }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -100,57 +101,45 @@ func TestVerifyIOUValue(t *testing.T) { func TestSerializeXrpAmount(t *testing.T) { tests := []struct { name string - input string + input types.XRPCurrencyAmount expectedOutput []byte expErr error }{ { name: "valid xrp value - 1", - input: "524801", + input: 524801, expectedOutput: []byte{0x40, 0x00, 0x00, 0x00, 0x00, 0x8, 0x2, 0x01}, expErr: nil, }, { name: "valid xrp value - 2", - input: "7696581656832", + input: 7696581656832, expectedOutput: []byte{0x40, 0x00, 0x7, 0x00, 0x00, 0x4, 0x1, 0x00}, expErr: nil, }, { name: "valid xrp value - 3", - input: "10000000", + input: 10000000, expectedOutput: []byte{0x40, 0x00, 0x00, 0x00, 0x00, 0x98, 0x96, 0x80}, expErr: nil, }, - { - name: "invalid xrp value - negative", - input: "-125000708", - expectedOutput: nil, - expErr: &InvalidAmountError{Amount: "-125000708"}, - }, - { - name: "invalid xrp value - decimal", - input: "125000708.0", - expectedOutput: nil, - expErr: ErrInvalidXRPValue, - }, { name: "boundary test - 1 less than max xrp value", - input: "99999999999999999", + input: 99999999999999999, expectedOutput: []byte{0x41, 0x63, 0x45, 0x78, 0x5d, 0x89, 0xff, 0xff}, expErr: nil, }, { name: "boundary test - max xrp value", - input: "10000000000000000", + input: 10000000000000000, expectedOutput: []byte{0x40, 0x23, 0x86, 0xf2, 0x6f, 0xc1, 0x00, 0x00}, expErr: nil, }, { name: "boundary test - 1 greater than max xrp value", - input: "100000000000000001", + input: 100000000000000001, expectedOutput: nil, - expErr: &InvalidAmountError{Amount: "100000000000000001"}, + expErr: &InvalidAmountError{Amount: 100000000000000001}, }, } for _, tt := range tests { @@ -232,7 +221,7 @@ func TestSerializeIssuedCurrencyValue(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := SerializeIssuedCurrencyValue(tt.input) + got, err := serializeIssuedCurrencyValue(tt.input) if tt.expectedErr != nil { require.EqualError(t, tt.expectedErr, err.Error()) @@ -349,35 +338,38 @@ func TestSerializeIssuedCurrencyCode(t *testing.T) { func TestSerializeIssuedCurrencyAmount(t *testing.T) { tests := []struct { - name string - inputValue string - inputCurrency string - inputIssuer string - expected []byte - expectedErr error + name string + input types.IssuedCurrencyAmount + // inputValue string + // inputCurrency string + // inputIssuer string + expected []byte + expectedErr error }{ { - name: "valid serialized issued currency amount", - inputValue: "7072.8", - inputCurrency: "USD", - inputIssuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - expected: []byte{0xD5, 0x59, 0x20, 0xAC, 0x93, 0x91, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x53, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x20, 0xB3, 0xC8, 0x5F, 0x48, 0x25, 0x32, 0xA9, 0x57, 0x8D, 0xBB, 0x39, 0x50, 0xB8, 0x5C, 0xA0, 0x65, 0x94, 0xD1}, - expectedErr: nil, - }, - { - name: "valid serialized issued currency amount - 2", - inputValue: "0.6275558355", - inputCurrency: "USD", - inputIssuer: "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", - expected: []byte{0xd4, 0x56, 0x4b, 0x96, 0x4a, 0x84, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x53, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0xd3, 0x3b, 0x18, 0xd5, 0x33, 0x85, 0xf8, 0xa3, 0x18, 0x55, 0x16, 0xc2, 0xed, 0xa5, 0xde, 0xdb, 0x8a, 0xc5, 0xc6}, - expectedErr: nil, + name: "valid serialized issued currency amount", + input: types.IssuedCurrencyAmount{ + Value: "7072.8", + Currency: "USD", + Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + }, + expected: []byte{0xD5, 0x59, 0x20, 0xAC, 0x93, 0x91, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x53, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x20, 0xB3, 0xC8, 0x5F, 0x48, 0x25, 0x32, 0xA9, 0x57, 0x8D, 0xBB, 0x39, 0x50, 0xB8, 0x5C, 0xA0, 0x65, 0x94, 0xD1}, + expectedErr: nil, }, + // { + // name: "valid serialized issued currency amount - 2", + // inputValue: "0.6275558355", + // inputCurrency: "USD", + // inputIssuer: "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", + // expected: []byte{0xd4, 0x56, 0x4b, 0x96, 0x4a, 0x84, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x53, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0xd3, 0x3b, 0x18, 0xd5, 0x33, 0x85, 0xf8, 0xa3, 0x18, 0x55, 0x16, 0xc2, 0xed, 0xa5, 0xde, 0xdb, 0x8a, 0xc5, 0xc6}, + // expectedErr: nil, + // }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := serializeIssuedCurrencyAmount(tt.inputValue, tt.inputCurrency, tt.inputIssuer) + got, err := serializeIssuedCurrencyAmount(tt.input) if tt.expectedErr != nil { require.EqualError(t, tt.expectedErr, err.Error()) diff --git a/binary-codec/types/pathset.go b/binary-codec/types/pathset.go index 06a9fafc..d38fc7f3 100644 --- a/binary-codec/types/pathset.go +++ b/binary-codec/types/pathset.go @@ -6,6 +6,7 @@ import ( addresscodec "github.com/CreatureDev/xrpl-go/address-codec" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/model/transactions" ) const ( @@ -26,16 +27,20 @@ var ErrInvalidPathSet error = errors.New("invalid type to construct PathSet from // FromJson attempts to serialize a path set from a JSON representation of a slice of paths to a byte array. // It returns the byte array representation of the path set, or an error if the provided json does not represent a valid path set. func (p PathSet) FromJson(json any) ([]byte, error) { - - if _, ok := json.([]any)[0].([]any); !ok { + // var pathSet [][]transactions.PathStep + // if pathSet, ok := json.([][]transactions.PathStep); !ok { + // return nil, ErrInvalidPathSet + // } + pathSet, ok := json.([][]transactions.PathStep) + if !ok { return nil, ErrInvalidPathSet } - if !isPathSet(json.([]any)) { + if !isPathSet(pathSet) { return nil, ErrInvalidPathSet } - return newPathSet(json.([]any)), nil + return newPathSet(pathSet), nil } // ToJson decodes a path set from a binary representation using a provided binary parser, then translates it to a JSON representation. @@ -87,35 +92,35 @@ func (p PathSet) ToJson(parser *serdes.BinaryParser, opts ...int) (any, error) { // isPathSet determines if an array represents a valid path set. // It checks if the array is either empty or if its first element is a valid path step. -func isPathSet(v []any) bool { - return len(v) == 0 || len(v[0].([]any)) == 0 || isPathStep(v[0].([]any)[0].(map[string]any)) +func isPathSet(v [][]transactions.PathStep) bool { + return len(v) == 0 || len(v[0]) == 0 || isPathStep(v[0][0]) } // isPathStep determines if a map represents a valid path step. // It checks if any of the keys "account", "currency" or "issuer" are present in the map. -func isPathStep(v map[string]any) bool { - return v["account"] != nil || v["currency"] != nil || v["issuer"] != nil +func isPathStep(v transactions.PathStep) bool { + return v.Account != "" || v.Currency != "" || v.Issuer != "" } // newPathStep creates a path step from a map representation. // It generates a byte array representation of the path step, encoding account, currency, and issuer information as appropriate. -func newPathStep(v map[string]any) []byte { +func newPathStep(v transactions.PathStep) []byte { dataType := 0x00 b := make([]byte, 0) - if v["account"] != nil { - _, account, _ := addresscodec.DecodeClassicAddressToAccountID(v["account"].(string)) + if v.Account != "" { + _, account, _ := addresscodec.DecodeClassicAddressToAccountID(string(v.Account)) b = append(b, account...) dataType |= typeAccount } - if v["currency"] != nil { - currency, _ := serializeIssuedCurrencyCode(v["currency"].(string)) + if v.Currency != "" { + currency, _ := serializeIssuedCurrencyCode(v.Currency) b = append(b, currency...) dataType |= typeCurrency } - if v["issuer"] != nil { - _, issuer, _ := addresscodec.DecodeClassicAddressToAccountID(v["issuer"].(string)) + if v.Issuer != "" { + _, issuer, _ := addresscodec.DecodeClassicAddressToAccountID(string(v.Issuer)) b = append(b, issuer...) dataType |= typeIssuer } @@ -125,26 +130,26 @@ func newPathStep(v map[string]any) []byte { // newPath constructs a path from a slice of path steps. // It generates a byte array representation of the path, encoding each path step in turn. -func newPath(v []any) []byte { +func newPath(v []transactions.PathStep) []byte { b := make([]byte, 0) for _, step := range v { // for each step in the path (slice of path steps) - b = append(b, newPathStep(step.(map[string]any))...) // append the path step to the byte array + b = append(b, newPathStep(step)...) // append the path step to the byte array } return b } // newPathSet constructs a path set from a slice of paths. // It generates a byte array representation of the path set, encoding each path and adding padding and path separators as appropriate. -func newPathSet(v []any) []byte { +func newPathSet(v [][]transactions.PathStep) []byte { b := make([]byte, 0) padding := make([]byte, 20) for _, path := range v { // for each path in the path set (slice of paths) - b = append(b, newPath(path.([]any))...) // append the path to the byte array - b = append(b, padding...) // append 20 empty bytes to the byte array between paths - b = append(b, pathSeparatorByte) // between each path, append a path separator byte + b = append(b, newPath(path)...) // append the path to the byte array + b = append(b, padding...) // append 20 empty bytes to the byte array between paths + b = append(b, pathSeparatorByte) // between each path, append a path separator byte } b[len(b)-1] = pathsetEndByte // replace last path separator with path set end byte diff --git a/binary-codec/types/pathset_test.go b/binary-codec/types/pathset_test.go index 9d54f8b1..4369a510 100644 --- a/binary-codec/types/pathset_test.go +++ b/binary-codec/types/pathset_test.go @@ -3,37 +3,38 @@ package types import ( "testing" - "github.com/stretchr/testify/require" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/stretchr/testify/require" ) func TestIsPathStep(t *testing.T) { tt := []struct { description string - input map[string]any + input transactions.PathStep expected bool }{ { description: "represents valid path step", - input: map[string]any{ - "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "currency": "USD", - "issuer": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + input: transactions.PathStep{ + Account: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + Currency: "USD", + Issuer: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", }, expected: true, }, { description: "represents valid path step", - input: map[string]any{ - "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "currency": "USD", + input: transactions.PathStep{ + Account: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + Currency: "USD", }, expected: true, }, { description: "represents invalid path step", - input: map[string]any{}, + input: transactions.PathStep{}, expected: false, }, } @@ -49,15 +50,15 @@ func TestNewPathStep(t *testing.T) { tt := []struct { description string - input map[string]any + input transactions.PathStep expected []byte }{ { description: "created valid path step", - input: map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + input: transactions.PathStep{ + Account: "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", + Currency: "USD", + Issuer: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", }, expected: []byte{0x31, 0x88, 0xa5, 0xa5, 0x7c, 0x82, 0x9f, 0x40, 0xf2, 0x5e, 0xa8, 0x33, 0x85, 0xbb, 0xde, 0x6c, 0x3d, 0x8b, 0x4c, 0xa0, 0x82, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x55, 0x53, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x52, 0xc7, 0xf0, 0x1a, 0xd1, 0x3b, 0x3c, 0xa9, 0xc1, 0xd1, 0x33, 0xfa, 0x8f, 0x34, 0x82, 0xd2, 0xef, 0x8, 0xfa, 0x7d}, }, @@ -74,21 +75,21 @@ func TestNewPath(t *testing.T) { tt := []struct { description string - input []any + input []transactions.PathStep expected []byte }{ { description: "created valid path", - input: []any{ - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + input: []transactions.PathStep{ + { + Account: "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", + Currency: "USD", + Issuer: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", }, - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + { + Account: "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", + Currency: "USD", + Issuer: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", }, }, expected: []byte{0x31, 0x88, 0xa5, 0xa5, 0x7c, 0x82, 0x9f, 0x40, 0xf2, 0x5e, 0xa8, 0x33, 0x85, 0xbb, 0xde, 0x6c, 0x3d, 0x8b, 0x4c, 0xa0, 0x82, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x55, 0x53, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x52, 0xc7, 0xf0, 0x1a, 0xd1, 0x3b, 0x3c, 0xa9, 0xc1, 0xd1, 0x33, 0xfa, 0x8f, 0x34, 0x82, 0xd2, 0xef, 0x8, 0xfa, 0x7d, 0x31, 0x88, 0xa5, 0xa5, 0x7c, 0x82, 0x9f, 0x40, 0xf2, 0x5e, 0xa8, 0x33, 0x85, 0xbb, 0xde, 0x6c, 0x3d, 0x8b, 0x4c, 0xa0, 0x82, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x55, 0x53, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x52, 0xc7, 0xf0, 0x1a, 0xd1, 0x3b, 0x3c, 0xa9, 0xc1, 0xd1, 0x33, 0xfa, 0x8f, 0x34, 0x82, 0xd2, 0xef, 0x8, 0xfa, 0x7d}, @@ -106,46 +107,46 @@ func TestNewPath(t *testing.T) { func TestNewPathSet(t *testing.T) { tt := []struct { description string - input []any + input [][]transactions.PathStep expected []byte }{ { description: "created valid path set with multiple paths", - input: []any{ - []any{ - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + input: [][]transactions.PathStep{ + { + { + Account: "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", + Currency: "USD", + Issuer: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", }, - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + { + Account: "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", + Currency: "USD", + Issuer: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", }, }, - []any{ - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + { + { + Account: "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", + Currency: "USD", + Issuer: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", }, - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + { + Account: "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", + Currency: "USD", + Issuer: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", }, }, - []any{ - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + { + { + Account: "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", + Currency: "USD", + Issuer: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", }, - map[string]any{ - "account": "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", - "currency": "USD", - "issuer": "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + { + Account: "rDTXLQ7ZKZVKz33zJbHjgVShjsBnqMBhmN", + Currency: "USD", + Issuer: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", }, }, }, diff --git a/binary-codec/types/st_array.go b/binary-codec/types/st_array.go index d752bc8e..1ffdb395 100644 --- a/binary-codec/types/st_array.go +++ b/binary-codec/types/st_array.go @@ -2,6 +2,7 @@ package types import ( "errors" + "reflect" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) @@ -22,19 +23,29 @@ var ErrNotSTObjectInSTArray = errors.New("not STObject in STArray. Array fields // of an STObject, appending the resulting byte slice to a "sink" slice. // The method returns an error if the JSON value is not a slice. func (t *STArray) FromJson(json any) ([]byte, error) { - if _, ok := json.([]any); !ok { + rv := reflect.ValueOf(json) + if rv.Kind() != reflect.Slice { return nil, ErrNotSTObjectInSTArray } - var sink []byte - for _, v := range json.([]any) { + for i := 0; i < rv.Len(); i++ { st := &STObject{} - b, err := st.FromJson(v) + val := rv.Index(i).Interface() + b, err := st.FromJson(val) if err != nil { return nil, err } sink = append(sink, b...) } + + // for _, v := range json.([]any) { + // st := &STObject{} + // b, err := st.FromJson(v) + // if err != nil { + // return nil, err + // } + // sink = append(sink, b...) + // } sink = append(sink, ArrayEndMarker) return sink, nil diff --git a/binary-codec/types/st_object.go b/binary-codec/types/st_object.go index cd668f36..be7a792c 100644 --- a/binary-codec/types/st_object.go +++ b/binary-codec/types/st_object.go @@ -1,11 +1,11 @@ package types import ( - "fmt" "sort" "github.com/CreatureDev/xrpl-go/binary-codec/definitions" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/mitchellh/mapstructure" ) // STObject represents a map of serialized field instances, where each key is a field name @@ -19,10 +19,17 @@ type STObject struct{} // This method returns an error if the JSON input is not a valid object. func (t *STObject) FromJson(json any) ([]byte, error) { s := serdes.NewSerializer() - if _, ok := json.(map[string]any); !ok { - return nil, fmt.Errorf("not a valid json node") + var m map[string]any + dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", Result: &m, Squash: true}) + if err != nil { + return nil, err } - fimap, err := createFieldInstanceMapFromJson(json.(map[string]any)) + err = dec.Decode(json) + if err != nil { + return nil, err + } + + fimap, err := createFieldInstanceMapFromJson(m) if err != nil { return nil, err @@ -94,6 +101,48 @@ func (t *STObject) ToJson(p *serdes.BinaryParser, opts ...int) (any, error) { return m, nil } +// type fieldInstanceMap map[definitions.FieldInstance]any + +// func (f fieldInstanceMap) addFieldInstanceFromMap(rv reflect.Value) error { +// if rv.Kind() != reflect.Map { +// return errors.New("not of type map") +// } + +// iter := rv.MapRange() +// for iter.Next() { +// fi, err := definitions.Get().GetFieldInstanceByFieldName(iter.Key().String()) +// if err != nil { +// return err +// } +// f[*fi] = iter.Value().Interface() +// } +// return nil +// } + +// func (f fieldInstanceMap) addFieldInstanceFromStruct(rv reflect.Value) error { +// if rv.Kind() != reflect.Struct { +// return errors.New("not of type struct") +// } +// for i := 0; i < rv.NumField(); i++ { + +// rvField := rv.Type().Field(i) +// if rvField.Name == "BaseTx" { +// continue +// } +// if rv.Field(i).IsZero() { +// continue +// } +// fi, err := definitions.Get().GetFieldInstanceByFieldName(rvField.Name) + +// if err != nil { +// return err +// } + +// f[*fi] = rv.Field(i).Interface() +// } +// return nil +// } + // nolint // createFieldInstanceMapFromJson creates a map of field instances from a JSON object. // Each key-value pair in the JSON object is converted into a field instance, where the key @@ -113,6 +162,23 @@ func createFieldInstanceMapFromJson(json map[string]any) (map[definitions.FieldI m[*fi] = v } return m, nil + // rv := reflect.ValueOf(json) + // m := make(fieldInstanceMap) + // switch rv.Kind() { + // case reflect.Map: + // err := m.addFieldInstanceFromMap(rv) + // if err != nil { + // return nil, err + // } + // case reflect.Struct: + // err := m.addFieldInstanceFromStruct(rv) + // if err != nil { + // return nil, err + // } + // default: + // return nil, errors.New("not a valid json node") + // } + // return m, nil } // nolint diff --git a/binary-codec/types/st_object_test.go b/binary-codec/types/st_object_test.go index ee9fc8c7..35c98dd0 100644 --- a/binary-codec/types/st_object_test.go +++ b/binary-codec/types/st_object_test.go @@ -1,48 +1,54 @@ package types import ( - "errors" "fmt" "testing" - "github.com/stretchr/testify/require" "github.com/CreatureDev/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" + "github.com/stretchr/testify/require" ) func TestCreateFieldInstanceMapFromJson(t *testing.T) { tt := []struct { description string - input map[string]interface{} - output map[definitions.FieldInstance]interface{} + input map[string]any + output map[definitions.FieldInstance]any expectedErr error }{ { description: "convert valid Json", - input: map[string]interface{}{ - "Fee": "10", - "Flags": 524288, - "OfferSequence": 1752791, - "TakerGets": "150000000000", + input: map[string]any{ + "Fee": types.XRPCurrencyAmount(10), + "Flags": uint(524288), + "OfferSequence": uint(1752791), + "TakerGets": types.XRPCurrencyAmount(150000000000), }, - output: map[definitions.FieldInstance]interface{}{ - getFieldInstance(t, "Fee"): "10", - getFieldInstance(t, "Flags"): 524288, - getFieldInstance(t, "OfferSequence"): 1752791, - getFieldInstance(t, "TakerGets"): "150000000000", + output: map[definitions.FieldInstance]any{ + getFieldInstance(t, "Fee"): types.XRPCurrencyAmount(10), + getFieldInstance(t, "Flags"): uint(524288), + getFieldInstance(t, "OfferSequence"): uint(1752791), + getFieldInstance(t, "TakerGets"): types.XRPCurrencyAmount(150000000000), }, expectedErr: nil, }, - { - description: "not found error", - input: map[string]interface{}{ - "IncorrectField": 89, - "Flags": 525288, - "OfferSequence": 1752791, - }, - output: nil, - expectedErr: errors.New("FieldName IncorrectField not found"), - }, + // { + // description: "not found error", + // input: &invalidTxWithBase{ + // InvalidField: "invalid", + // }, + // output: nil, + // expectedErr: errors.New("FieldName InvalidField not found"), + // }, + // { + // description: "no base tx", + // input: &invalidTx{ + // InvalidField: "invalid", + // }, + // output: nil, + // expectedErr: errors.New("no base tx defined"), + // }, } for _, tc := range tt { @@ -53,7 +59,7 @@ func TestCreateFieldInstanceMapFromJson(t *testing.T) { require.EqualError(t, err, tc.expectedErr.Error()) } else { require.NoError(t, err) - require.Equal(t, tc.output, got) + require.EqualValues(t, tc.output, got) } }) } diff --git a/binary-codec/types/uint16.go b/binary-codec/types/uint16.go index 9ae76f92..80ada5b0 100644 --- a/binary-codec/types/uint16.go +++ b/binary-codec/types/uint16.go @@ -6,6 +6,8 @@ import ( "github.com/CreatureDev/xrpl-go/binary-codec/definitions" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions" ) // UInt16 represents a 16-bit unsigned integer. @@ -15,25 +17,45 @@ type UInt16 struct{} // If the input value is a string, it's assumed to be a transaction type or ledger entry type name, and the // method will attempt to convert it into a corresponding type code. If the conversion fails, an error is returned. func (u *UInt16) FromJson(value any) ([]byte, error) { - - if _, ok := value.(string); ok { - tc, err := definitions.Get().GetTransactionTypeCodeByTransactionTypeName(value.(string)) + switch v := value.(type) { + case transactions.TxType: + tc, err := definitions.Get().GetTransactionTypeCodeByTransactionTypeName(string(v)) if err != nil { - tc, err = definitions.Get().GetLedgerEntryTypeCodeByLedgerEntryTypeName(value.(string)) - if err != nil { - return nil, err - } + return nil, err + } + value = int(tc) + case ledger.LedgerEntryType: + tc, err := definitions.Get().GetLedgerEntryTypeCodeByLedgerEntryTypeName(string(v)) + if err != nil { + return nil, err } value = int(tc) } - buf := new(bytes.Buffer) err := binary.Write(buf, binary.BigEndian, uint16(value.(int))) - if err != nil { return nil, err } return buf.Bytes(), nil + + // if _, ok := value.(string); ok { + // tc, err := definitions.Get().GetTransactionTypeCodeByTransactionTypeName(value.(string)) + // if err != nil { + // tc, err = definitions.Get().GetLedgerEntryTypeCodeByLedgerEntryTypeName(value.(string)) + // if err != nil { + // return nil, err + // } + // } + // value = int(tc) + // } + + // buf := new(bytes.Buffer) + // err := binary.Write(buf, binary.BigEndian, uint16(value.(int))) + + // if err != nil { + // return nil, err + // } + // return buf.Bytes(), nil } // ToJson takes a BinaryParser and optional parameters, and converts the serialized byte data diff --git a/binary-codec/types/uint32.go b/binary-codec/types/uint32.go index f9a776aa..6355900d 100644 --- a/binary-codec/types/uint32.go +++ b/binary-codec/types/uint32.go @@ -14,7 +14,7 @@ type UInt32 struct{} // The input value is assumed to be an integer. If the serialization fails, an error is returned. func (u *UInt32) FromJson(value any) ([]byte, error) { buf := new(bytes.Buffer) - err := binary.Write(buf, binary.BigEndian, uint32(value.(int))) + err := binary.Write(buf, binary.BigEndian, uint32(value.(uint))) if err != nil { return nil, err diff --git a/model/transactions/escrow_finish.go b/model/transactions/escrow_finish.go index 1b6f8560..74deeddf 100644 --- a/model/transactions/escrow_finish.go +++ b/model/transactions/escrow_finish.go @@ -5,7 +5,7 @@ import ( ) type EscrowFinish struct { - BaseTx + BaseTx `mapstructure:",squash"` Owner types.Address OfferSequence uint Condition string `json:",omitempty"` From 92c4967526307dd8d269d2868f6b5bd448e568c6 Mon Sep 17 00:00:00 2001 From: JCrawsh Date: Tue, 19 Sep 2023 20:19:59 +0100 Subject: [PATCH 23/32] chore: made uint a helper method to return a pointer --- binary-codec/main_test.go | 100 +++++++++--------- binary-codec/types/uint32.go | 12 ++- model/client/admin/signing/sign_for_test.go | 4 +- model/client/admin/signing/sign_test.go | 2 +- .../transactions/submit_multisigned_test.go | 4 +- model/client/transactions/submit_test.go | 2 +- model/client/transactions/tx_test.go | 2 +- .../transactions/nftoken_create_offer_test.go | 2 +- model/transactions/nftoken_mint_test.go | 2 +- model/transactions/payment_test.go | 2 +- model/transactions/trust_set_test.go | 2 +- model/transactions/tx.go | 2 +- model/transactions/types/uint.go | 9 ++ 13 files changed, 82 insertions(+), 63 deletions(-) create mode 100644 model/transactions/types/uint.go diff --git a/binary-codec/main_test.go b/binary-codec/main_test.go index 9fb198ed..90d2996c 100644 --- a/binary-codec/main_test.go +++ b/binary-codec/main_test.go @@ -140,55 +140,55 @@ func TestEncode(t *testing.T) { // output: "6680000000000000000000000000000000000000004C5543000000000020A85019EA62B48F79EB67273B797EB916438FA4", // expectedErr: nil, // }, - // { - // description: "successfully serialized signed transaction 1", - // input: &transactions.OfferCreate{ - // BaseTx: transactions.BaseTx{ - // Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - // TransactionType: transactions.OfferCreateTx, - // Fee: 10, - // Flags: 524288, - // Sequence: 1752792, - // SigningPubKey: "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", - // TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", - // }, - // Expiration: 595640108, - // OfferSequence: 1752791, - // TakerGets: types.XRPCurrencyAmount(15000000000), - // TakerPays: types.IssuedCurrencyAmount{ - // Currency: "USD", - // Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - // Value: "7072.8", - // }, - // }, - // output: "120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3744630440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C8114DD76483FACDEE26E60D8A586BB58D09F27045C46", - // expectedErr: nil, - // }, - // { - // description: "successfully serialized signed transaction 2", - // input: &transactions.EscrowFinish{ - // BaseTx: transactions.BaseTx{ - // Account: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", - // TransactionType: transactions.EscrowFinishTx, - // Fee: 10101, - // Flags: 2147483648, - // Sequence: 1, - // SigningPubKey: "0268D79CD579D077750740FA18A2370B7C2018B2714ECE70BA65C38D223E79BC9C", - // TxnSignature: "3045022100F06FB54049D6D50142E5CF2E2AC21946AF305A13E2A2D4BA881B36484DD01A540220311557EC8BEF536D729605A4CB4D4DC51B1E37C06C93434DD5B7651E1E2E28BF", - // Memos: []transactions.MemoWrapper{ - // { - // Memo: transactions.Memo{ - // MemoData: "04C4D46544659A2D58525043686174", - // }, - // }, - // }, - // }, - // OfferSequence: 11, - // Owner: "r9NpyVfLfUG8hatuCCHKzosyDtKnBdsEN3", - // }, - // output: "1200022280000000240000000120190000000B68400000000000277573210268D79CD579D077750740FA18A2370B7C2018B2714ECE70BA65C38D223E79BC9C74473045022100F06FB54049D6D50142E5CF2E2AC21946AF305A13E2A2D4BA881B36484DD01A540220311557EC8BEF536D729605A4CB4D4DC51B1E37C06C93434DD5B7651E1E2E28BF811452C7F01AD13B3CA9C1D133FA8F3482D2EF08FA7D82145A380FBD236B6A1CD14B939AD21101E5B6B6FFA2F9EA7D0F04C4D46544659A2D58525043686174E1F1", - // expectedErr: nil, - // }, + { + description: "successfully serialized signed transaction 1", + input: &transactions.OfferCreate{ + BaseTx: transactions.BaseTx{ + Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + TransactionType: transactions.OfferCreateTx, + Fee: 10, + Flags: types.Uint(524288), + Sequence: 1752792, + SigningPubKey: "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", + TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", + }, + Expiration: 595640108, + OfferSequence: 1752791, + TakerGets: types.XRPCurrencyAmount(15000000000), + TakerPays: types.IssuedCurrencyAmount{ + Currency: "USD", + Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + Value: "7072.8", + }, + }, + output: "120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3744630440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C8114DD76483FACDEE26E60D8A586BB58D09F27045C46", + expectedErr: nil, + }, + { + description: "successfully serialized signed transaction 2", + input: &transactions.EscrowFinish{ + BaseTx: transactions.BaseTx{ + Account: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", + TransactionType: transactions.EscrowFinishTx, + Fee: 10101, + Flags: types.Uint(2147483648), + Sequence: 1, + SigningPubKey: "0268D79CD579D077750740FA18A2370B7C2018B2714ECE70BA65C38D223E79BC9C", + TxnSignature: "3045022100F06FB54049D6D50142E5CF2E2AC21946AF305A13E2A2D4BA881B36484DD01A540220311557EC8BEF536D729605A4CB4D4DC51B1E37C06C93434DD5B7651E1E2E28BF", + Memos: []transactions.MemoWrapper{ + { + Memo: transactions.Memo{ + MemoData: "04C4D46544659A2D58525043686174", + }, + }, + }, + }, + OfferSequence: 11, + Owner: "r9NpyVfLfUG8hatuCCHKzosyDtKnBdsEN3", + }, + output: "1200022280000000240000000120190000000B68400000000000277573210268D79CD579D077750740FA18A2370B7C2018B2714ECE70BA65C38D223E79BC9C74473045022100F06FB54049D6D50142E5CF2E2AC21946AF305A13E2A2D4BA881B36484DD01A540220311557EC8BEF536D729605A4CB4D4DC51B1E37C06C93434DD5B7651E1E2E28BF811452C7F01AD13B3CA9C1D133FA8F3482D2EF08FA7D82145A380FBD236B6A1CD14B939AD21101E5B6B6FFA2F9EA7D0F04C4D46544659A2D58525043686174E1F1", + expectedErr: nil, + }, { description: "successfully serialized signed transaction 3", input: &transactions.Payment{ @@ -196,7 +196,7 @@ func TestEncode(t *testing.T) { Account: "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", TransactionType: transactions.PaymentTx, Fee: 12, - Flags: 0, + Flags: types.Uint(0), Sequence: 842, Memos: []transactions.MemoWrapper{ { diff --git a/binary-codec/types/uint32.go b/binary-codec/types/uint32.go index 6355900d..1a6b664b 100644 --- a/binary-codec/types/uint32.go +++ b/binary-codec/types/uint32.go @@ -3,6 +3,7 @@ package types import ( "bytes" "encoding/binary" + "reflect" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) @@ -13,8 +14,9 @@ type UInt32 struct{} // FromJson converts a JSON value into a serialized byte slice representing a 32-bit unsigned integer. // The input value is assumed to be an integer. If the serialization fails, an error is returned. func (u *UInt32) FromJson(value any) ([]byte, error) { + v := expandInt(value) buf := new(bytes.Buffer) - err := binary.Write(buf, binary.BigEndian, uint32(value.(uint))) + err := binary.Write(buf, binary.BigEndian, uint32(v.(uint))) if err != nil { return nil, err @@ -32,3 +34,11 @@ func (u *UInt32) ToJson(p *serdes.BinaryParser, opts ...int) (any, error) { } return int(binary.BigEndian.Uint32(b)), nil } + +func expandInt(v any) any { + rv := reflect.ValueOf(v) + if rv.Kind() == reflect.Ptr { + return rv.Elem().Interface() + } + return v +} diff --git a/model/client/admin/signing/sign_for_test.go b/model/client/admin/signing/sign_for_test.go index ef25b901..91576630 100644 --- a/model/client/admin/signing/sign_for_test.go +++ b/model/client/admin/signing/sign_for_test.go @@ -17,7 +17,7 @@ func TestSignForRequest(t *testing.T) { BaseTx: transactions.BaseTx{ TransactionType: transactions.TrustSetTx, Account: "rEuLyBCvcw4CFmzv8RepSiAoNgF8tTGJQC", - Flags: 262144, + Flags: types.Uint(262144), Sequence: 2, Fee: types.XRPCurrencyAmount(30000), }, @@ -60,7 +60,7 @@ func TestSignForResponse(t *testing.T) { TransactionType: transactions.TrustSetTx, Fee: types.XRPCurrencyAmount(30000), Sequence: 2, - Flags: 262144, + Flags: types.Uint(262144), Signers: []transactions.Signer{ { SignerData: transactions.SignerData{ diff --git a/model/client/admin/signing/sign_test.go b/model/client/admin/signing/sign_test.go index 04de7eee..0b0ec9f8 100644 --- a/model/client/admin/signing/sign_test.go +++ b/model/client/admin/signing/sign_test.go @@ -55,7 +55,7 @@ func TestSignResponse(t *testing.T) { TransactionType: transactions.TrustSetTx, Fee: types.XRPCurrencyAmount(30000), Sequence: 2, - Flags: 262144, + Flags: types.Uint(262144), Signers: []transactions.Signer{ { SignerData: transactions.SignerData{ diff --git a/model/client/transactions/submit_multisigned_test.go b/model/client/transactions/submit_multisigned_test.go index d147be7a..097d3775 100644 --- a/model/client/transactions/submit_multisigned_test.go +++ b/model/client/transactions/submit_multisigned_test.go @@ -22,7 +22,7 @@ func TestSubmitMultisignedRequest(t *testing.T) { TransactionType: "Payment", Fee: types.XRPCurrencyAmount(10000), Sequence: 360, - Flags: 2147483648, + Flags: types.Uint(2147483648), SigningPubKey: "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB", TxnSignature: "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580", Signers: []transactions.Signer{ @@ -104,7 +104,7 @@ func TestSubmitMultisignedResponse(t *testing.T) { TransactionType: "Payment", Fee: types.XRPCurrencyAmount(10000), Sequence: 360, - Flags: 2147483648, + Flags: types.Uint(2147483648), SigningPubKey: "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB", TxnSignature: "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580", Signers: []transactions.Signer{ diff --git a/model/client/transactions/submit_test.go b/model/client/transactions/submit_test.go index 07b4799d..e0dceb1e 100644 --- a/model/client/transactions/submit_test.go +++ b/model/client/transactions/submit_test.go @@ -48,7 +48,7 @@ func TestSubmitResponse(t *testing.T) { TransactionType: "Payment", Fee: types.XRPCurrencyAmount(10000), Sequence: 360, - Flags: 2147483648, + Flags: types.Uint(2147483648), SigningPubKey: "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB", TxnSignature: "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580", }, diff --git a/model/client/transactions/tx_test.go b/model/client/transactions/tx_test.go index e41fbabf..5b4abb22 100644 --- a/model/client/transactions/tx_test.go +++ b/model/client/transactions/tx_test.go @@ -18,7 +18,7 @@ func TestTxResponse(t *testing.T) { TransactionType: transactions.OfferCreateTx, Account: "rhhh49pFH96roGyuC4E5P4CHaNjS1k8gzM", Fee: types.XRPCurrencyAmount(12), - Flags: 0, + Flags: types.Uint(0), LastLedgerSequence: 56865248, Sequence: 5037710, SigningPubKey: "03B51A3EDF70E4098DA7FB053A01C5A6A0A163A30ED1445F14F87C7C3295FCB3BE", diff --git a/model/transactions/nftoken_create_offer_test.go b/model/transactions/nftoken_create_offer_test.go index 27809deb..5177c32e 100644 --- a/model/transactions/nftoken_create_offer_test.go +++ b/model/transactions/nftoken_create_offer_test.go @@ -14,7 +14,7 @@ func TestNFTokenCreateOfferTx(t *testing.T) { BaseTx: BaseTx{ Account: "rs8jBmmfpwgmrSPgwMsh7CvKRmRt1JTVSX", TransactionType: NFTokenCreateOfferTx, - Flags: 1, + Flags: types.Uint(1), }, NFTokenID: "000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007", Amount: types.XRPCurrencyAmount(1000000), diff --git a/model/transactions/nftoken_mint_test.go b/model/transactions/nftoken_mint_test.go index f24387a0..d908531c 100644 --- a/model/transactions/nftoken_mint_test.go +++ b/model/transactions/nftoken_mint_test.go @@ -15,7 +15,7 @@ func TestNFTokenMintTx(t *testing.T) { Account: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", TransactionType: NFTokenMintTx, Fee: types.XRPCurrencyAmount(10), - Flags: 8, + Flags: types.Uint(8), Memos: []MemoWrapper{ { Memo: Memo{ diff --git a/model/transactions/payment_test.go b/model/transactions/payment_test.go index 4220c982..8a0f78e0 100644 --- a/model/transactions/payment_test.go +++ b/model/transactions/payment_test.go @@ -15,7 +15,7 @@ func TestPaymentTx(t *testing.T) { Account: "abc", TransactionType: PaymentTx, Fee: types.XRPCurrencyAmount(1000), - Flags: 262144, + Flags: types.Uint(262144), }, Amount: types.IssuedCurrencyAmount{ Issuer: "def", diff --git a/model/transactions/trust_set_test.go b/model/transactions/trust_set_test.go index 366be3c6..62a4c329 100644 --- a/model/transactions/trust_set_test.go +++ b/model/transactions/trust_set_test.go @@ -15,7 +15,7 @@ func TestTrustSetTx(t *testing.T) { Account: "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", TransactionType: TrustSetTx, Fee: types.XRPCurrencyAmount(12), - Flags: 262144, + Flags: types.Uint(262144), Sequence: 12, LastLedgerSequence: 8007750, }, diff --git a/model/transactions/tx.go b/model/transactions/tx.go index 5eb84b6d..5f46a235 100644 --- a/model/transactions/tx.go +++ b/model/transactions/tx.go @@ -31,7 +31,7 @@ type BaseTx struct { Fee types.XRPCurrencyAmount `json:",omitempty"` Sequence uint `json:",omitempty"` AccountTxnID types.Hash256 `json:",omitempty"` - Flags uint `json:",omitempty"` + Flags *uint `json:",omitempty"` LastLedgerSequence uint `json:",omitempty"` Memos []MemoWrapper `json:",omitempty"` Signers []Signer `json:",omitempty"` diff --git a/model/transactions/types/uint.go b/model/transactions/types/uint.go new file mode 100644 index 00000000..2068232f --- /dev/null +++ b/model/transactions/types/uint.go @@ -0,0 +1,9 @@ +package types + +// Uint is a helper function that allocates a new uint value +// to store v and returns a pointer to it. +func Uint(v uint) *uint { + p := new(uint) + *p = v + return p +} From ce86a095b6e4da85da866dc52f858af5fbec8d25 Mon Sep 17 00:00:00 2001 From: JCrawsh Date: Mon, 23 Oct 2023 22:26:27 +0100 Subject: [PATCH 24/32] chore: added flag interface and fixed st array tests --- .pre-commit-config.yaml | 2 +- binary-codec/main_test.go | 219 +----------- binary-codec/st_array_test.go | 316 ------------------ binary-codec/types/amount_test.go | 15 +- binary-codec/types/hash.go | 44 --- binary-codec/types/hash128.go | 48 ++- binary-codec/types/hash160.go | 40 ++- binary-codec/types/hash256.go | 46 ++- binary-codec/types/st_array.go | 10 +- binary-codec/types/st_array_test.go | 201 +++++++++++ binary-codec/types/st_object.go | 11 + binary-codec/types/uint32.go | 17 +- binary-codec/types/vector256.go | 21 +- model/client/account/account_info_test.go | 2 +- model/client/account/offer_result.go | 10 +- model/client/account/queue_data.go | 4 +- model/client/admin/signing/sign_for_test.go | 4 +- model/client/admin/signing/sign_test.go | 2 +- model/client/clio/nft_info_response.go | 2 +- model/client/ledger/ledger_data_test.go | 1 + model/client/ledger/ledger_entry_test.go | 2 +- .../transactions/submit_multisigned_test.go | 4 +- model/client/transactions/submit_response.go | 8 +- model/client/transactions/submit_test.go | 2 +- model/client/transactions/tx_test.go | 8 +- model/ledger/account_root.go | 8 +- model/ledger/account_root_test.go | 2 +- model/ledger/amendments.go | 2 +- model/ledger/check.go | 2 +- model/ledger/deposit_preauth.go | 4 +- model/ledger/directory_node.go | 2 +- model/ledger/directory_node_test.go | 4 +- model/ledger/escrow.go | 4 +- model/ledger/fee_settings.go | 2 +- model/ledger/ledger_hashes.go | 6 +- model/ledger/negative_unl.go | 4 +- model/ledger/nftoken_offer.go | 8 +- model/ledger/nftoken_page.go | 2 +- model/ledger/offer.go | 16 +- model/ledger/pay_channel.go | 4 +- model/ledger/ripple_state.go | 2 +- model/ledger/signer_list.go | 6 +- model/ledger/ticket.go | 6 +- model/transactions/account_set.go | 6 +- model/transactions/escrow_cancel.go | 2 +- model/transactions/escrow_finish.go | 2 +- .../transactions/nftoken_create_offer_test.go | 2 +- model/transactions/nftoken_mint_test.go | 2 +- model/transactions/offer_cancel.go | 2 +- model/transactions/offer_create.go | 8 +- model/transactions/payment_test.go | 2 +- model/transactions/transaction_metadata.go | 4 +- model/transactions/trust_set_test.go | 2 +- model/transactions/tx.go | 8 +- model/transactions/types/flags.go | 20 ++ model/transactions/types/uint.go | 9 - 56 files changed, 478 insertions(+), 714 deletions(-) delete mode 100644 binary-codec/st_array_test.go create mode 100644 binary-codec/types/st_array_test.go create mode 100644 model/transactions/types/flags.go delete mode 100644 model/transactions/types/uint.go diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f87d8a19..3b9f7e26 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: rev: v0.5.0 hooks: - id: go-fmt - # - id: go-unit-tests + - id: go-unit-tests - id: go-mod-tidy - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook rev: v9.5.0 diff --git a/binary-codec/main_test.go b/binary-codec/main_test.go index 90d2996c..6048ed43 100644 --- a/binary-codec/main_test.go +++ b/binary-codec/main_test.go @@ -15,131 +15,6 @@ func TestEncode(t *testing.T) { output string expectedErr error }{ - // { - // description: "large test tx", - // input: &transactions.OfferCreate{ - // BaseTx: transactions.BaseTx{ - // Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - // TransactionType: transactions.OfferCreateTx, - // Fee: 10, - // Flags: 524288, - // Sequence: 1752792, - // SigningPubKey: "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", - // TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", - // Memos: []transactions.MemoWrapper{ - // { - // Memo: transactions.Memo{ - // MemoData: "04C4D46544659A2D58525043686174", - // }, - // }, - // }, - // }, - // Expiration: 595640108, - // OfferSequence: 1752791, - // TakerGets: types.XRPCurrencyAmount(15000000000), - // TakerPays: types.IssuedCurrencyAmount{ - // Currency: "USD", - // Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - // Value: "7072.8", - // }, - - // // "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", - // // "Expiration": 595640108, - // // "Fee": "10", - // // "Flags": 524288, - // // "OfferSequence": 1752791, - // // "Sequence": 1752792, - // // "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", - // // "TakerGets": "15000000000", - // // "TakerPays": map[string]any{ - // // "currency": "USD", - // // "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", - // // "value": "7072.8", - // // }, - // // "TransactionType": "OfferCreate", - // // "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", - // // "Paths": []any{ - // // []any{ - // // map[string]any{ - // // "account": "rPDXxSZcuVL3ZWoyU82bcde3zwvmShkRyF", - // // "type": 1, - // // "type_hex": "0000000000000001", - // // }, - // // map[string]any{ - // // "currency": "XRP", - // // "type": 16, - // // "type_hex": "0000000000000010", - // // }, - // // }, - // // []any{ - // // map[string]any{ - // // "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - // // "type": 1, - // // "type_hex": "0000000000000001", - // // }, - // // map[string]any{ - // // "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", - // // "type": 1, - // // "type_hex": "0000000000000001", - // // }, - // // map[string]any{ - // // "currency": "XRP", - // // "type": 16, - // // "type_hex": "0000000000000010", - // // }, - // // }, - // // []any{ - // // map[string]any{ - // // "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", - // // "type": 1, - // // "type_hex": "0000000000000001", - // // }, - // // map[string]any{ - // // "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", - // // "type": 1, - // // "type_hex": "0000000000000001", - // // }, - // // map[string]any{ - // // "currency": "XRP", - // // "type": 16, - // // "type_hex": "0000000000000010", - // // }, - // // }, - // // }, - // // "Memos": []any{ - // // map[string]any{ - // // "Memo": map[string]any{ - // // "MemoData": "04C4D46544659A2D58525043686174", - // // }, - // // }, - // // // }, - // // "LedgerEntryType": "RippleState", - // // "TransferFee": 30874, - // // "CloseResolution": 25, - // // "OwnerNode": "0000018446744073", - // // "Amendments": []string{ - // // "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - // // "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - // // }, - // // "EmailHash": "73734B611DDA23D3F5F62E20A173B78A", - // // "TakerPaysCurrency": "73734B611DDA23D3F5F62E20A173B78AB8406AC5", - // // "Digest": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - // }, - // output: "11007212000714789A220008000024001ABED82A2380BF2C2019001ABED73400000184467440734173734B611DDA23D3F5F62E20A173B78A501573734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C64D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3744630440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C8114DD76483FACDEE26E60D8A586BB58D09F27045C46F9EA7D0F04C4D46544659A2D58525043686174E1F1011019011173734B611DDA23D3F5F62E20A173B78AB8406AC5011201F3B1997562FD742B54D4EBDEA1D6AEA3D4906B8F100000000000000000000000000000000000000000FF014B4E9C06F24296074F7BC48F92A97916C6DC5EA901DD39C650A96EDA48334E70CC4A85B8B2E8502CD3100000000000000000000000000000000000000000FF014B4E9C06F24296074F7BC48F92A97916C6DC5EA901DD39C650A96EDA48334E70CC4A85B8B2E8502CD31000000000000000000000000000000000000000000003134073734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - // expectedErr: nil, - // }, - // { - // description: "zero issued currency amount", - // input: map[string]any{ - // "LowLimit": map[string]any{ - // "currency": "LUC", - // "issuer": "rsygE5ynt2iSasscfCCeqaGBGiFKMCAUu7", - // "value": "0", - // }, - // }, - // output: "6680000000000000000000000000000000000000004C5543000000000020A85019EA62B48F79EB67273B797EB916438FA4", - // expectedErr: nil, - // }, { description: "successfully serialized signed transaction 1", input: &transactions.OfferCreate{ @@ -147,7 +22,7 @@ func TestEncode(t *testing.T) { Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", TransactionType: transactions.OfferCreateTx, Fee: 10, - Flags: types.Uint(524288), + Flags: types.SetFlag(524288), Sequence: 1752792, SigningPubKey: "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", @@ -171,7 +46,7 @@ func TestEncode(t *testing.T) { Account: "r3Y6vCE8XqfZmYBRngy22uFYkmz3y9eCRA", TransactionType: transactions.EscrowFinishTx, Fee: 10101, - Flags: types.Uint(2147483648), + Flags: types.SetFlag(2147483648), Sequence: 1, SigningPubKey: "0268D79CD579D077750740FA18A2370B7C2018B2714ECE70BA65C38D223E79BC9C", TxnSignature: "3045022100F06FB54049D6D50142E5CF2E2AC21946AF305A13E2A2D4BA881B36484DD01A540220311557EC8BEF536D729605A4CB4D4DC51B1E37C06C93434DD5B7651E1E2E28BF", @@ -196,7 +71,7 @@ func TestEncode(t *testing.T) { Account: "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", TransactionType: transactions.PaymentTx, Fee: 12, - Flags: types.Uint(0), + Flags: types.SetFlag(0), Sequence: 842, Memos: []transactions.MemoWrapper{ { @@ -242,94 +117,6 @@ func TestEncode(t *testing.T) { expectedErr: nil, output: "1200002200000000240000034A201B009717BE61400000000098968068400000000000000C69D4564B964A845AC0000000000000000000000000555344000000000069D33B18D53385F8A3185516C2EDA5DEDB8AC5C673210379F17CFA0FFD7518181594BE69FE9A10471D6DE1F4055C6D2746AFD6CF89889E74473045022100D55ED1953F860ADC1BC5CD993ABB927F48156ACA31C64737865F4F4FF6D015A80220630704D2BD09C8E99F26090C25F11B28F5D96A1350454402C2CED92B39FFDBAF811469D33B18D53385F8A3185516C2EDA5DEDB8AC5C6831469D33B18D53385F8A3185516C2EDA5DEDB8AC5C6F9EA7C06636C69656E747D077274312E312E31E1F1011201F3B1997562FD742B54D4EBDEA1D6AEA3D4906B8F100000000000000000000000000000000000000000FF014B4E9C06F24296074F7BC48F92A97916C6DC5EA901DD39C650A96EDA48334E70CC4A85B8B2E8502CD310000000000000000000000000000000000000000000", }, - // { - // description: "serialize OwnerNode example - UInt64", - // input: map[string]any{"OwnerNode": "18446744073"}, - // output: "340000018446744073", - // expectedErr: nil, - // }, - // { - // description: "serialize LedgerEntryType example - UInt8", - // input: map[string]any{"LedgerEntryType": "RippleState"}, - // output: "110072", - // expectedErr: nil, - // }, - // { - // description: "serialize int example - UInt8", - // input: map[string]any{"CloseResolution": 25}, - // output: "011019", - // expectedErr: nil, - // }, - // { - // description: "serialize hash 128", - // input: map[string]any{"EmailHash": "73734B611DDA23D3F5F62E20A173B78A"}, - // output: "4173734B611DDA23D3F5F62E20A173B78A", - // expectedErr: nil, - // }, - // { - // description: "hash128 wrong length", - // input: map[string]any{"EmailHash": "73734B611DDA23D3F5F62E20A173"}, - // output: "", - // expectedErr: &types.ErrInvalidHashLength{Expected: 16}, - // }, - // { - // description: "serialize hash 160", - // input: map[string]any{"TakerPaysCurrency": "73734B611DDA23D3F5F62E20A173B78AB8406AC5"}, - // output: "011173734B611DDA23D3F5F62E20A173B78AB8406AC5", - // expectedErr: nil, - // }, - // { - // description: "hash160 wrong length", - // input: map[string]any{"TakerPaysCurrency": "73734B611DDA23D3F5F62E20A173B789"}, - // output: "", - // expectedErr: &types.ErrInvalidHashLength{Expected: 20}, - // }, - // { - // description: "serialize hash 256", - // input: map[string]any{"Digest": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C"}, - // output: "501573734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - // expectedErr: nil, - // }, - // { - // description: "hash256 wrong length", - // input: map[string]any{"Digest": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F537"}, - // output: "", - // expectedErr: &types.ErrInvalidHashLength{Expected: 32}, - // }, - // { - // description: "serialize Vector256 successfully,", - // input: map[string]any{"Amendments": []string{"73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C"}}, - // output: "03134073734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", - // expectedErr: nil, - // }, - // { - // description: "invalid input for Vector256 - not a string array", - // input: map[string]any{"Amendments": []int{1, 2, 3}}, - // output: "", - // expectedErr: &types.ErrInvalidVector256Type{Got: "[]int"}, - // }, - // { - // description: "invalid input for Vector256 - wrong hash length", - // input: map[string]any{"Amendments": []string{"73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C56342689", "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06"}}, - // output: "", - // expectedErr: &types.ErrInvalidHashLength{Expected: types.HashLengthBytes}, - // }, - // { - // description: "serialize STObject correctly", - // input: &transactions.OfferCreate{ - // BaseTx: transactions.BaseTx{ - // Memos: []transactions.MemoWrapper{ - // { - // Memo: transactions.Memo{ - // MemoType: "04C4D46544659A2D58525043686174", - // }, - // }, - // }, - // }, - // }, - // output: "F9EA7C0F04C4D46544659A2D58525043686174E1F1", - // expectedErr: nil, - // }, } for _, tc := range tt { diff --git a/binary-codec/st_array_test.go b/binary-codec/st_array_test.go deleted file mode 100644 index 6da37c70..00000000 --- a/binary-codec/st_array_test.go +++ /dev/null @@ -1,316 +0,0 @@ -package binarycodec - -// import ( -// "testing" - -// "github.com/stretchr/testify/require" -// ) - -// func TestSTArrayFromJson(t *testing.T) { -// tt := []struct { -// description string -// input map[string]any -// output string -// expectedErr error -// }{ -// { -// description: "nested stobject test", -// input: map[string]any{ -// "AffectedNodes": []any{ -// map[string]any{ -// "DeletedNode": map[string]any{ -// "FinalFields": map[string]any{ -// "ExchangeRate": "4a0745621d069432", -// "Flags": 0, -// "RootIndex": "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", -// "TakerGetsCurrency": "0000000000000000000000000000000000000000", -// "TakerGetsIssuer": "0000000000000000000000000000000000000000", -// "TakerPaysCurrency": "0000000000000000000000004254430000000000", -// "TakerPaysIssuer": "06A148131B436B2561C85967685B098E050EED4E", -// }, -// "LedgerEntryType": "DirectoryNode", -// "LedgerIndex": "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", -// }, -// }, -// map[string]any{ -// "ModifiedNode": map[string]any{ -// "FinalFields": map[string]any{ -// "Flags": 0, -// "Owner": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", -// "RootIndex": "5ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC", -// }, -// "LedgerEntryType": "DirectoryNode", -// "LedgerIndex": "5ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC", -// }, -// }, -// map[string]any{ -// "DeletedNode": map[string]any{ -// "FinalFields": map[string]any{ -// "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", -// "BookDirectory": "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", -// "BookNode": "0", -// "Flags": 131072, -// "OwnerNode": "0", -// "PreviousTxnID": "B21E9DC8DCB75AD12C4ACF4C72E6E822244CF6CFFD7BD738ACEED1264374B687", -// "PreviousTxnLgrSeq": 82010985, -// "Sequence": 59434311, -// "TakerGets": "1166610661", -// "TakerPays": map[string]any{ -// "currency": "BTC", -// "issuer": "rchGBxcD1A1C2tdxF6papQYZ8kjRKMYcL", -// "value": "0.023876", -// }, -// }, -// "LedgerEntryType": "Offer", -// "LedgerIndex": "C171AA6003AE67B218E5EFFEF3E49CB5A4FE5A06D82C1F7EEF322B036EF76CE7", -// }, -// }, -// map[string]any{ -// "ModifiedNode": map[string]any{ -// "FinalFields": map[string]any{ -// "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", -// "Balance": "3310960263", -// "Flags": 0, -// "MessageKey": "020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144", -// "OwnerCount": 8, -// "Sequence": 59434319, -// }, -// "LedgerEntryType": "AccountRoot", -// "LedgerIndex": "F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1", -// "PreviousFields": map[string]any{ -// "Balance": "3310960413", -// "OwnerCount": 9, -// "Sequence": 59434318, -// }, -// "PreviousTxnID": "DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE683", -// "PreviousTxnLgrSeq": 82011654, -// }, -// }, -// }, -// "TransactionIndex": 31, -// "TransactionResult": "tesSUCCESS", -// }, -// output: "201C0000001FF8E411006456036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432E72200000000364A0745621D06943258036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D06943201110000000000000000000000004254430000000000021106A148131B436B2561C85967685B098E050EED4E0311000000000000000000000000000000000000000004110000000000000000000000000000000000000000E1E1E5110064565ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFCE72200000000585ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC821407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1E411006F56C171AA6003AE67B218E5EFFEF3E49CB5A4FE5A06D82C1F7EEF322B036EF76CE7E7220002000024038AE5472504E3636933000000000000000034000000000000000055B21E9DC8DCB75AD12C4ACF4C72E6E822244CF6CFFD7BD738ACEED1264374B6875010036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D06943264D4087B8271DDA000000000000000000000000000425443000000000006A148131B436B2561C85967685B098E050EED4E6540000000458910E5811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1E51100612504E3660655DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE68356F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1E624038AE54E2D000000096240000000C5593F1DE1E7220000000024038AE54F2D000000086240000000C5593E877221020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1F1031000", -// expectedErr: nil, -// }, -// { -// description: "large starray test", -// input: map[string]any{ -// "AffectedNodes": []any{ -// map[string]any{ -// "ModifiedNode": map[string]any{ -// "LedgerEntryType": "NFTokenPage", -// "LedgerIndex": "1D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291", -// "PreviousFields": map[string]any{ -// "NFTokens": []any{ -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// map[string]any{ -// "Signer": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// map[string]any{ -// "Majority": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// map[string]any{ -// "DisabledValidator": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// }, -// }, -// "PreviousTxnID": "0D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF", -// "PreviousTxnLgrSeq": 81744044, -// }, -// "DeletedNode": map[string]any{ -// "LedgerEntryType": "NFTokenPage", -// "LedgerIndex": "1D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291", -// "PreviousFields": map[string]any{ -// "NFTokens": []any{ -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// }, -// }, -// "PreviousTxnID": "0D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF", -// "PreviousTxnLgrSeq": 81744044, -// }, -// }, -// map[string]any{ -// "ModifiedNode": map[string]any{ -// "LedgerEntryType": "NFTokenPage", -// "LedgerIndex": "1D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291", -// "PreviousFields": map[string]any{ -// "NFTokens": []any{ -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA", -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// }, -// }, -// "PreviousTxnID": "0D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF", -// "PreviousTxnLgrSeq": 81744044, -// }, -// }, -// }, -// "TransactionIndex": 55, -// "TransactionResult": "tesSUCCESS", -// }, -// output: "201C00000037F8E41100502504DF50AC550D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF561D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291E6FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1E1E1E51100502504DF50AC550D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF561D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291E6FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1E0105A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1E0125A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1E0135A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1E1E1E51100502504DF50AC550D46A35F56587D5FFF36551AF712E07E5617665BD5C52615B5AE7A338904C1BF561D8CE533B1355B905B5C75F85B1F9A5149B94D7B49B94D7BC3CD6D2D00000291E6FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAF373F1C00001382754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BAFBD1B9100000CF5754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1EC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BB17CF754000013BA754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1E1E1F1031000", -// expectedErr: nil, -// }, -// } - -// for _, tc := range tt { -// t.Run(tc.description, func(t *testing.T) { -// got, err := Encode(tc.input) - -// if tc.expectedErr != nil { -// require.EqualError(t, err, tc.expectedErr.Error()) -// require.Empty(t, got) -// } else { -// require.NoError(t, err) -// require.Equal(t, tc.output, got) -// } -// }) -// } - -// } - -// func TestSTArrayToJson(t *testing.T) { -// tt := []struct { -// description string -// input string -// output map[string]any -// expectedErr error -// }{ -// { -// description: "large starray", -// input: "FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9E1E010754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1", -// output: map[string]any{ -// "NFTokens": []any{ -// map[string]any{ -// "NFToken": map[string]any{ -// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", -// }, -// }, -// map[string]any{ -// "Signer": map[string]any{ -// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", -// }, -// }, -// }, -// }, -// expectedErr: nil, -// }, -// { -// description: "simple starray", -// input: "F9EA364A0745621D0694327D0F04C4D46544659A2D58525043686174E1E9364A0745621D0694327D0F04C4D46544659A2D58525043686174E1F1", -// output: map[string]any{ -// "Memos": []any{ -// map[string]any{ -// "Memo": map[string]any{ -// "MemoData": "04C4D46544659A2D58525043686174", -// "ExchangeRate": "4A0745621D069432", -// }, -// }, -// map[string]any{ -// "TemplateEntry": map[string]any{ -// "MemoData": "04C4D46544659A2D58525043686174", -// "ExchangeRate": "4A0745621D069432", -// }, -// }, -// }, -// }, -// }, -// { -// description: "smaller stobject test", -// input: "E51100612504E3660655DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE68356F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1E624038AE54E2D000000096240000000C5593F1DE1E7220000000024038AE54F2D000000086240000000C5593E877221020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1", -// output: map[string]any{ -// "ModifiedNode": map[string]any{ -// "FinalFields": map[string]any{ -// "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", -// "Balance": "3310960263", -// "Flags": 0, -// "MessageKey": "020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144", -// "OwnerCount": 8, -// "Sequence": 59434319, -// }, -// "LedgerEntryType": "AccountRoot", -// "LedgerIndex": "F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1", -// "PreviousFields": map[string]any{ -// "Balance": "3310960413", -// "OwnerCount": 9, -// "Sequence": 59434318, -// }, -// "PreviousTxnID": "DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE683", -// "PreviousTxnLgrSeq": 82011654, -// }, -// }, -// }, -// } - -// for _, tc := range tt { -// t.Run(tc.description, func(t *testing.T) { -// act, err := Decode(tc.input) -// if tc.expectedErr != nil { -// require.Error(t, err, tc.expectedErr.Error()) -// require.Nil(t, act) -// } else { -// require.NoError(t, err) -// require.EqualValues(t, tc.output, act) -// } -// }) -// } -// } diff --git a/binary-codec/types/amount_test.go b/binary-codec/types/amount_test.go index 263206ed..d40d00cf 100644 --- a/binary-codec/types/amount_test.go +++ b/binary-codec/types/amount_test.go @@ -338,11 +338,8 @@ func TestSerializeIssuedCurrencyCode(t *testing.T) { func TestSerializeIssuedCurrencyAmount(t *testing.T) { tests := []struct { - name string - input types.IssuedCurrencyAmount - // inputValue string - // inputCurrency string - // inputIssuer string + name string + input types.IssuedCurrencyAmount expected []byte expectedErr error }{ @@ -356,14 +353,6 @@ func TestSerializeIssuedCurrencyAmount(t *testing.T) { expected: []byte{0xD5, 0x59, 0x20, 0xAC, 0x93, 0x91, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x53, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x20, 0xB3, 0xC8, 0x5F, 0x48, 0x25, 0x32, 0xA9, 0x57, 0x8D, 0xBB, 0x39, 0x50, 0xB8, 0x5C, 0xA0, 0x65, 0x94, 0xD1}, expectedErr: nil, }, - // { - // name: "valid serialized issued currency amount - 2", - // inputValue: "0.6275558355", - // inputCurrency: "USD", - // inputIssuer: "rweYz56rfmQ98cAdRaeTxQS9wVMGnrdsFp", - // expected: []byte{0xd4, 0x56, 0x4b, 0x96, 0x4a, 0x84, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x53, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0xd3, 0x3b, 0x18, 0xd5, 0x33, 0x85, 0xf8, 0xa3, 0x18, 0x55, 0x16, 0xc2, 0xed, 0xa5, 0xde, 0xdb, 0x8a, 0xc5, 0xc6}, - // expectedErr: nil, - // }, } for _, tt := range tests { diff --git a/binary-codec/types/hash.go b/binary-codec/types/hash.go index ee298a8f..c41bd99b 100644 --- a/binary-codec/types/hash.go +++ b/binary-codec/types/hash.go @@ -1,11 +1,7 @@ package types import ( - "encoding/hex" "fmt" - "strings" - - "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) // ErrInvalidHashLength struct is used when the hash length does not meet the expected value. @@ -23,43 +19,3 @@ type hashI interface { SerializedType getLength() int } - -// hash struct represents a hash with a specific length. -type hash struct { - Length int -} - -// newHash is a constructor for creating a new hash with a specified length. -func newHash(l int) hash { - return hash{ - Length: l, - } -} - -// getLength method for hash returns the hash's length. -func (h hash) getLength() int { - return h.Length -} - -// FromJson method for hash converts a hexadecimal string from JSON to a byte array. -// It returns an error if the conversion fails or the length of the decoded byte array is not as expected. -func (h hash) FromJson(json any) ([]byte, error) { - v, err := hex.DecodeString(json.(string)) - if err != nil { - return nil, err - } - if h.getLength() != len(v) { - return nil, &ErrInvalidHashLength{Expected: h.getLength()} - } - return v, nil -} - -// ToJson method for hash reads a certain number of bytes from a BinaryParser and converts it into a hexadecimal string. -// It returns an error if the read operation fails. -func (h hash) ToJson(p *serdes.BinaryParser, opts ...int) (any, error) { - b, err := p.ReadBytes(h.Length) - if err != nil { - return nil, err - } - return strings.ToUpper(hex.EncodeToString(b)), nil -} diff --git a/binary-codec/types/hash128.go b/binary-codec/types/hash128.go index 97c59ea3..621ad257 100644 --- a/binary-codec/types/hash128.go +++ b/binary-codec/types/hash128.go @@ -1,13 +1,55 @@ package types +import ( + "encoding/hex" + "strings" + + "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/xyield/xrpl-go/model/transactions/types" +) + +var _ hashI = (*Hash128)(nil) + // Hash128 struct represents a 128-bit hash. type Hash128 struct { - hashI } // NewHash128 is a constructor for creating a new 128-bit hash. func NewHash128() *Hash128 { - return &Hash128{ - newHash(16), + return &Hash128{} +} + +// getLength method for hash returns the hash's length. +func (h *Hash128) getLength() int { + return 16 +} + +// FromJson method for hash converts a hexadecimal string from JSON to a byte array. +// It returns an error if the conversion fails or the length of the decoded byte array is not as expected. +func (h *Hash128) FromJson(json any) ([]byte, error) { + var s string + switch json := json.(type) { + case string: + s = json + case types.Hash128: + s = string(json) + } + v, err := hex.DecodeString(s) + if err != nil { + return nil, err + } + if h.getLength() != len(v) { + return nil, &ErrInvalidHashLength{Expected: h.getLength()} + } + return v, nil +} + +// ToJson method for hash reads a certain number of bytes from a BinaryParser and converts it into a hexadecimal string. +// It returns an error if the read operation fails. +func (h *Hash128) ToJson(p *serdes.BinaryParser, opts ...int) (any, error) { + b, err := p.ReadBytes(h.getLength()) + if err != nil { + return nil, err } + return strings.ToUpper(hex.EncodeToString(b)), nil } diff --git a/binary-codec/types/hash160.go b/binary-codec/types/hash160.go index c02a12d1..c4999d90 100644 --- a/binary-codec/types/hash160.go +++ b/binary-codec/types/hash160.go @@ -1,13 +1,47 @@ package types +import ( + "encoding/hex" + "strings" + + "github.com/xyield/xrpl-go/binary-codec/serdes" +) + +var _ hashI = (*Hash128)(nil) + // Hash160 struct represents a 160-bit hash. type Hash160 struct { - hashI } // NewHash160 is a constructor for creating a new 160-bit hash. func NewHash160() *Hash160 { - return &Hash160{ - newHash(20), + return &Hash160{} +} + +// getLength method for hash returns the hash's length. +func (h *Hash160) getLength() int { + return 20 +} + +// FromJson method for hash converts a hexadecimal string from JSON to a byte array. +// It returns an error if the conversion fails or the length of the decoded byte array is not as expected. +func (h *Hash160) FromJson(json any) ([]byte, error) { + v, err := hex.DecodeString(json.(string)) + if err != nil { + return nil, err + } + if h.getLength() != len(v) { + return nil, &ErrInvalidHashLength{Expected: h.getLength()} + } + return v, nil +} + +// ToJson method for hash reads a certain number of bytes from a BinaryParser and converts it into a hexadecimal string. +// It returns an error if the read operation fails. +func (h *Hash160) ToJson(p *serdes.BinaryParser, opts ...int) (any, error) { + b, err := p.ReadBytes(h.getLength()) + if err != nil { + return nil, err } + return strings.ToUpper(hex.EncodeToString(b)), nil } diff --git a/binary-codec/types/hash256.go b/binary-codec/types/hash256.go index 3c690e49..6e152fe4 100644 --- a/binary-codec/types/hash256.go +++ b/binary-codec/types/hash256.go @@ -1,13 +1,53 @@ package types +import ( + "encoding/hex" + "strings" + + "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/xyield/xrpl-go/model/transactions/types" +) + +var _ hashI = (*Hash256)(nil) + // Hash256 struct represents a 256-bit hash. type Hash256 struct { - hashI } // NewHash256 is a constructor for creating a new 256-bit hash. func NewHash256() *Hash256 { - return &Hash256{ - newHash(32), + return &Hash256{} +} + +// getLength method for hash returns the hash's length. +func (h *Hash256) getLength() int { + return 32 +} + +func (h *Hash256) FromJson(json any) ([]byte, error) { + var s string + switch json := json.(type) { + case string: + s = json + case types.Hash256: + s = string(json) + } + v, err := hex.DecodeString(s) + if err != nil { + return nil, err + } + if h.getLength() != len(v) { + return nil, &ErrInvalidHashLength{Expected: h.getLength()} + } + return v, nil +} + +// ToJson method for hash reads a certain number of bytes from a BinaryParser and converts it into a hexadecimal string. +// It returns an error if the read operation fails. +func (h *Hash256) ToJson(p *serdes.BinaryParser, opts ...int) (any, error) { + b, err := p.ReadBytes(h.getLength()) + if err != nil { + return nil, err } + return strings.ToUpper(hex.EncodeToString(b)), nil } diff --git a/binary-codec/types/st_array.go b/binary-codec/types/st_array.go index 1ffdb395..37613bfb 100644 --- a/binary-codec/types/st_array.go +++ b/binary-codec/types/st_array.go @@ -29,8 +29,8 @@ func (t *STArray) FromJson(json any) ([]byte, error) { } var sink []byte for i := 0; i < rv.Len(); i++ { - st := &STObject{} val := rv.Index(i).Interface() + st := &STObject{} b, err := st.FromJson(val) if err != nil { return nil, err @@ -38,14 +38,6 @@ func (t *STArray) FromJson(json any) ([]byte, error) { sink = append(sink, b...) } - // for _, v := range json.([]any) { - // st := &STObject{} - // b, err := st.FromJson(v) - // if err != nil { - // return nil, err - // } - // sink = append(sink, b...) - // } sink = append(sink, ArrayEndMarker) return sink, nil diff --git a/binary-codec/types/st_array_test.go b/binary-codec/types/st_array_test.go new file mode 100644 index 00000000..fd705271 --- /dev/null +++ b/binary-codec/types/st_array_test.go @@ -0,0 +1,201 @@ +package types + +import ( + "encoding/hex" + "strings" + "testing" + + "github.com/stretchr/testify/require" + "github.com/xyield/xrpl-go/model/ledger" + "github.com/xyield/xrpl-go/model/transactions" + "github.com/xyield/xrpl-go/model/transactions/types" +) + +func TestSTArrayFromJson(t *testing.T) { + tt := []struct { + description string + input any + output string + expectedErr error + }{ + { + description: "nested stobject test", + input: []transactions.AffectedNode{ + { + DeletedNode: &transactions.DeletedNode{ + FinalFields: &ledger.DirectoryNode{ + Flags: types.SetFlag(0), + RootIndex: "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", + TakerGetsCurrency: "0000000000000000000000000000000000000000", + TakerGetsIssuer: "0000000000000000000000000000000000000000", + TakerPaysCurrency: "0000000000000000000000004254430000000000", + TakerPaysIssuer: "06A148131B436B2561C85967685B098E050EED4E", + }, + LedgerEntryType: ledger.DirectoryNodeEntry, + LedgerIndex: "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", + }, + }, + { + ModifiedNode: &transactions.ModifiedNode{ + FinalFields: &ledger.DirectoryNode{ + Flags: types.SetFlag(0), + Owner: "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", + RootIndex: "5ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC", + }, + LedgerEntryType: ledger.DirectoryNodeEntry, + LedgerIndex: "5ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC", + }, + }, + { + DeletedNode: &transactions.DeletedNode{ + FinalFields: &ledger.Offer{ + Account: "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", + BookDirectory: "036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432", + BookNode: "0", + Flags: 131072, + OwnerNode: "0", + PreviousTxnID: "B21E9DC8DCB75AD12C4ACF4C72E6E822244CF6CFFD7BD738ACEED1264374B687", + PreviousTxnLgrSeq: 82010985, + Sequence: 59434311, + TakerGets: types.XRPCurrencyAmount(1166610661), + TakerPays: types.IssuedCurrencyAmount{ + Currency: "BTC", + Issuer: "rchGBxcD1A1C2tdxF6papQYZ8kjRKMYcL", + Value: "0.023876", + }, + }, + LedgerEntryType: ledger.OfferEntry, + LedgerIndex: "C171AA6003AE67B218E5EFFEF3E49CB5A4FE5A06D82C1F7EEF322B036EF76CE7", + }, + }, + { + ModifiedNode: &transactions.ModifiedNode{ + FinalFields: &ledger.AccountRoot{ + Account: "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", + Balance: types.XRPCurrencyAmount(3310960263), + Flags: types.SetFlag(0), + MessageKey: "020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144", + OwnerCount: 8, + Sequence: 59434319, + }, + LedgerEntryType: ledger.AccountRootEntry, + LedgerIndex: "F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1", + PreviousFields: &ledger.AccountRoot{ + Balance: types.XRPCurrencyAmount(3310960413), + OwnerCount: 9, + Sequence: 59434318, + }, + PreviousTxnID: "DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE683", + PreviousTxnLgrSeq: 82011654, + }, + }, + }, + output: "E411006456036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D069432E7220000000058036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D06943201110000000000000000000000004254430000000000021106A148131B436B2561C85967685B098E050EED4E0311000000000000000000000000000000000000000004110000000000000000000000000000000000000000E1E1E5110064565ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFCE72200000000585ED0913938CD6D43BD6450201737394A9991753C4581E5682D61F35048D8FBFC821407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1E411006F56C171AA6003AE67B218E5EFFEF3E49CB5A4FE5A06D82C1F7EEF322B036EF76CE7E7220002000024038AE5472504E3636933000000000000000034000000000000000055B21E9DC8DCB75AD12C4ACF4C72E6E822244CF6CFFD7BD738ACEED1264374B6875010036D7E923EF22B65E19D95A6365C3373E1E96586E27015074A0745621D06943264D4087B8271DDA000000000000000000000000000425443000000000006A148131B436B2561C85967685B098E050EED4E6540000000458910E5811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1E51100612504E3660655DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE68356F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1E624038AE54E2D000000096240000000C5593F1DE1E7220000000024038AE54F2D000000086240000000C5593E877221020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1F1", + expectedErr: nil, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + sa := &STArray{} + got, err := sa.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.output, strings.ToUpper(hex.EncodeToString(got))) + } + }) + } + +} + +// func TestSTArrayToJson(t *testing.T) { +// tt := []struct { +// description string +// input string +// output map[string]any +// expectedErr error +// }{ +// { +// description: "large starray", +// input: "FAEC5A000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9E1E010754368747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476BE1F1", +// output: map[string]any{ +// "NFTokens": []any{ +// map[string]any{ +// "NFToken": map[string]any{ +// "NFTokenID": "000913881D8CE533B1355B905B5C75F85B1F9A5149B94D7BABAF4475000011D9", +// }, +// }, +// map[string]any{ +// "Signer": map[string]any{ +// "URI": "68747470733A2F2F697066732E696F2F697066732F516D57356232715736744D3975615659376E555162774356334D63514B566E6D5659516A6A4368784E65656B476B", +// }, +// }, +// }, +// }, +// expectedErr: nil, +// }, +// { +// description: "simple starray", +// input: "F9EA364A0745621D0694327D0F04C4D46544659A2D58525043686174E1E9364A0745621D0694327D0F04C4D46544659A2D58525043686174E1F1", +// output: map[string]any{ +// "Memos": []any{ +// map[string]any{ +// "Memo": map[string]any{ +// "MemoData": "04C4D46544659A2D58525043686174", +// "ExchangeRate": "4A0745621D069432", +// }, +// }, +// map[string]any{ +// "TemplateEntry": map[string]any{ +// "MemoData": "04C4D46544659A2D58525043686174", +// "ExchangeRate": "4A0745621D069432", +// }, +// }, +// }, +// }, +// }, +// { +// description: "smaller stobject test", +// input: "E51100612504E3660655DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE68356F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1E624038AE54E2D000000096240000000C5593F1DE1E7220000000024038AE54F2D000000086240000000C5593E877221020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144811407B6FEE98BBDD29F92FDFAF6107BC741C4130E8FE1E1", +// output: map[string]any{ +// "ModifiedNode": map[string]any{ +// "FinalFields": map[string]any{ +// "Account": "r68xfQkhFxZrbwo6RRKq728JF2fJYQRE1", +// "Balance": "3310960263", +// "Flags": 0, +// "MessageKey": "020000000000000000000000002B8F120A4CD1A6B236CC4389A30AB676CD722144", +// "OwnerCount": 8, +// "Sequence": 59434319, +// }, +// "LedgerEntryType": "AccountRoot", +// "LedgerIndex": "F8C1F1AE7AEF06FEFB2311232CA30A7803820A79AE65F567354629D579BB38B1", +// "PreviousFields": map[string]any{ +// "Balance": "3310960413", +// "OwnerCount": 9, +// "Sequence": 59434318, +// }, +// "PreviousTxnID": "DC99E25A951DBBF89D331428DFFE72880159C03D0A4F48EBC81A277CFFBCE683", +// "PreviousTxnLgrSeq": 82011654, +// }, +// }, +// }, +// } + +// for _, tc := range tt { +// t.Run(tc.description, func(t *testing.T) { +// p := serdes.NewBinaryParser([]byte(tc.input)) +// sa := &STArray{} +// act, err := sa.ToJson(p) +// if tc.expectedErr != nil { +// require.Error(t, err, tc.expectedErr.Error()) +// require.Nil(t, act) +// } else { +// require.NoError(t, err) +// require.EqualValues(t, tc.output, act) +// } +// }) +// } +// } diff --git a/binary-codec/types/st_object.go b/binary-codec/types/st_object.go index be7a792c..5fa47436 100644 --- a/binary-codec/types/st_object.go +++ b/binary-codec/types/st_object.go @@ -1,6 +1,7 @@ package types import ( + "reflect" "sort" "github.com/CreatureDev/xrpl-go/binary-codec/definitions" @@ -38,6 +39,10 @@ func (t *STObject) FromJson(json any) ([]byte, error) { sk := getSortedKeys(fimap) for _, v := range sk { + if checkZero(fimap[v]) { + continue + } + if !v.IsSerialized { continue } @@ -217,3 +222,9 @@ func enumToStr(fieldType string, value any) (any, error) { return value, nil } } + +// check for zero value +func checkZero(v any) bool { + rv := reflect.ValueOf(v) + return rv.IsZero() +} diff --git a/binary-codec/types/uint32.go b/binary-codec/types/uint32.go index 1a6b664b..229be01c 100644 --- a/binary-codec/types/uint32.go +++ b/binary-codec/types/uint32.go @@ -3,9 +3,9 @@ package types import ( "bytes" "encoding/binary" - "reflect" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) // UInt32 represents a 32-bit unsigned integer. @@ -16,7 +16,7 @@ type UInt32 struct{} func (u *UInt32) FromJson(value any) ([]byte, error) { v := expandInt(value) buf := new(bytes.Buffer) - err := binary.Write(buf, binary.BigEndian, uint32(v.(uint))) + err := binary.Write(buf, binary.BigEndian, v) if err != nil { return nil, err @@ -35,10 +35,13 @@ func (u *UInt32) ToJson(p *serdes.BinaryParser, opts ...int) (any, error) { return int(binary.BigEndian.Uint32(b)), nil } -func expandInt(v any) any { - rv := reflect.ValueOf(v) - if rv.Kind() == reflect.Ptr { - return rv.Elem().Interface() +func expandInt(v any) uint32 { + switch v := v.(type) { + case types.FlagsI: + return v.ToUint() + case uint: + return uint32(v) + default: + return v.(uint32) } - return v } diff --git a/binary-codec/types/vector256.go b/binary-codec/types/vector256.go index 17f0926f..aba60bd7 100644 --- a/binary-codec/types/vector256.go +++ b/binary-codec/types/vector256.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) const HashLengthBytes = 32 @@ -27,18 +28,18 @@ type Vector256 struct{} // The input value is assumed to be an array of strings representing Hash256 values. // If the serialization fails, an error is returned. func (v *Vector256) FromJson(json any) ([]byte, error) { - - if _, ok := json.([]string); !ok { + switch json := json.(type) { + case []string: + return vector256FromValue(json) + case []types.Hash256: + var values []string + for _, hash := range json { + values = append(values, string(hash)) + } + return vector256FromValue([]string(values)) + default: return nil, &ErrInvalidVector256Type{fmt.Sprintf("%T", json)} } - - b, err := vector256FromValue(json.([]string)) - - if err != nil { - return nil, err - } - - return b, nil } // vector256FromValue takes a slice of strings representing Hash256 values, diff --git a/model/client/account/account_info_test.go b/model/client/account/account_info_test.go index ef4d9a8a..977c5702 100644 --- a/model/client/account/account_info_test.go +++ b/model/client/account/account_info_test.go @@ -36,7 +36,7 @@ func TestAccountInfoResponse(t *testing.T) { AccountData: ledger.AccountRoot{ Account: "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn", Balance: types.XRPCurrencyAmount(999999999960), - Flags: 8388608, + Flags: types.SetFlag(8388608), LedgerEntryType: ledger.AccountRootEntry, OwnerCount: 0, PreviousTxnID: "4294BEBE5B569A18C0A2702387C9B1E7146DC3A5850C1E87204951C6FDAA4C42", diff --git a/model/client/account/offer_result.go b/model/client/account/offer_result.go index 1028e266..3c1bdbec 100644 --- a/model/client/account/offer_result.go +++ b/model/client/account/offer_result.go @@ -6,11 +6,15 @@ import ( "github.com/CreatureDev/xrpl-go/model/transactions/types" ) -type OfferResultFlags uint +type OfferResultFlags uint32 + +func (f OfferResultFlags) ToUint() uint32 { + return uint32(f) +} type OfferResult struct { Flags OfferResultFlags `json:"flags"` - Sequence uint `json:"seq"` + Sequence uint32 `json:"seq"` TakerGets types.CurrencyAmount `json:"taker_gets"` TakerPays types.CurrencyAmount `json:"taker_pays"` Quality string `json:"quality"` @@ -20,7 +24,7 @@ type OfferResult struct { func (r *OfferResult) UnmarshalJSON(data []byte) error { type orHelper struct { Flags OfferResultFlags `json:"flags"` - Sequence uint `json:"seq"` + Sequence uint32 `json:"seq"` TakerGets json.RawMessage `json:"taker_gets"` TakerPays json.RawMessage `json:"taker_pays"` Quality string `json:"quality"` diff --git a/model/client/account/queue_data.go b/model/client/account/queue_data.go index 3e2be541..123267fe 100644 --- a/model/client/account/queue_data.go +++ b/model/client/account/queue_data.go @@ -5,8 +5,8 @@ import "github.com/CreatureDev/xrpl-go/model/transactions/types" type QueueData struct { TxnCount uint64 `json:"txn_count"` AuthChangeQueued bool `json:"auth_change_queued,omitempty"` - LowestSequence uint64 `json:"lowest_sequence,omitempty"` - HighestSequence uint64 `json:"highest_sequence,omitempty"` + LowestSequence uint32 `json:"lowest_sequence,omitempty"` + HighestSequence uint32 `json:"highest_sequence,omitempty"` MaxSpendDropsTotal types.XRPCurrencyAmount `json:"max_spend_drops_total,omitempty"` Transactions []QueueTransaction `json:"transactions,omitempty"` } diff --git a/model/client/admin/signing/sign_for_test.go b/model/client/admin/signing/sign_for_test.go index 91576630..22c50bcb 100644 --- a/model/client/admin/signing/sign_for_test.go +++ b/model/client/admin/signing/sign_for_test.go @@ -17,7 +17,7 @@ func TestSignForRequest(t *testing.T) { BaseTx: transactions.BaseTx{ TransactionType: transactions.TrustSetTx, Account: "rEuLyBCvcw4CFmzv8RepSiAoNgF8tTGJQC", - Flags: types.Uint(262144), + Flags: types.SetFlag(262144), Sequence: 2, Fee: types.XRPCurrencyAmount(30000), }, @@ -60,7 +60,7 @@ func TestSignForResponse(t *testing.T) { TransactionType: transactions.TrustSetTx, Fee: types.XRPCurrencyAmount(30000), Sequence: 2, - Flags: types.Uint(262144), + Flags: types.SetFlag(262144), Signers: []transactions.Signer{ { SignerData: transactions.SignerData{ diff --git a/model/client/admin/signing/sign_test.go b/model/client/admin/signing/sign_test.go index 0b0ec9f8..85d00e9c 100644 --- a/model/client/admin/signing/sign_test.go +++ b/model/client/admin/signing/sign_test.go @@ -55,7 +55,7 @@ func TestSignResponse(t *testing.T) { TransactionType: transactions.TrustSetTx, Fee: types.XRPCurrencyAmount(30000), Sequence: 2, - Flags: types.Uint(262144), + Flags: types.SetFlag(262144), Signers: []transactions.Signer{ { SignerData: transactions.SignerData{ diff --git a/model/client/clio/nft_info_response.go b/model/client/clio/nft_info_response.go index 91c9d811..e4a4480a 100644 --- a/model/client/clio/nft_info_response.go +++ b/model/client/clio/nft_info_response.go @@ -14,6 +14,6 @@ type NFTInfoResponse struct { TransferFee uint `json:"transfer_fee"` Issuer types.Address `json:"issuer"` NFTokenTaxon uint `json:"nft_taxon"` - NFTokenSequence uint `json:"nft_sequence"` + NFTokenSequence uint32 `json:"nft_sequence"` URI types.NFTokenURI `json:"uri,omitempty"` } diff --git a/model/client/ledger/ledger_data_test.go b/model/client/ledger/ledger_data_test.go index 5682c7b1..10472768 100644 --- a/model/client/ledger/ledger_data_test.go +++ b/model/client/ledger/ledger_data_test.go @@ -36,6 +36,7 @@ func TestLedgerDataResponse(t *testing.T) { Account: "rKKzk9ghA2iuy3imqMXUHJqdRPMtNDGf4c", Balance: types.XRPCurrencyAmount(893730848), LedgerEntryType: ledger.AccountRootEntry, + Flags: types.SetFlag(0), PreviousTxnID: "C204A65CF2542946289A3358C67D991B5E135FABFA89F271DBA7A150C08CA046", PreviousTxnLgrSeq: 6487716, Sequence: 1, diff --git a/model/client/ledger/ledger_entry_test.go b/model/client/ledger/ledger_entry_test.go index 4c14e637..679b1a90 100644 --- a/model/client/ledger/ledger_entry_test.go +++ b/model/client/ledger/ledger_entry_test.go @@ -38,7 +38,7 @@ func TestLedgerEntryResponse(t *testing.T) { Balance: types.XRPCurrencyAmount(424021949), Domain: "6D64756F31332E636F6D", EmailHash: "98B4375E1D753E5B91627516F6D70977", - Flags: 9568256, + Flags: types.SetFlag(9568256), LedgerEntryType: ledger.AccountRootEntry, MessageKey: "0000000000000000000000070000000300", OwnerCount: 12, diff --git a/model/client/transactions/submit_multisigned_test.go b/model/client/transactions/submit_multisigned_test.go index 097d3775..5f6fcf86 100644 --- a/model/client/transactions/submit_multisigned_test.go +++ b/model/client/transactions/submit_multisigned_test.go @@ -22,7 +22,7 @@ func TestSubmitMultisignedRequest(t *testing.T) { TransactionType: "Payment", Fee: types.XRPCurrencyAmount(10000), Sequence: 360, - Flags: types.Uint(2147483648), + Flags: types.SetFlag(2147483648), SigningPubKey: "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB", TxnSignature: "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580", Signers: []transactions.Signer{ @@ -104,7 +104,7 @@ func TestSubmitMultisignedResponse(t *testing.T) { TransactionType: "Payment", Fee: types.XRPCurrencyAmount(10000), Sequence: 360, - Flags: types.Uint(2147483648), + Flags: types.SetFlag(2147483648), SigningPubKey: "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB", TxnSignature: "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580", Signers: []transactions.Signer{ diff --git a/model/client/transactions/submit_response.go b/model/client/transactions/submit_response.go index f7c75300..ee653d71 100644 --- a/model/client/transactions/submit_response.go +++ b/model/client/transactions/submit_response.go @@ -14,8 +14,8 @@ type SubmitResponse struct { TxBlob string `json:"tx_blob"` Tx transactions.Tx `json:"tx_json"` Accepted bool `json:"accepted"` - AccountSequenceAvailable uint `json:"account_sequence_available"` - AccountSequenceNext uint `json:"account_sequence_next"` + AccountSequenceAvailable uint32 `json:"account_sequence_available"` + AccountSequenceNext uint32 `json:"account_sequence_next"` Applied bool `json:"applied"` Broadcast bool `json:"broadcast"` Kept bool `json:"kept"` @@ -32,8 +32,8 @@ func (r *SubmitResponse) UnmarshalJSON(data []byte) error { TxBlob string `json:"tx_blob"` Tx json.RawMessage `json:"tx_json"` Accepted bool `json:"accepted"` - AccountSequenceAvailable uint `json:"account_sequence_available"` - AccountSequenceNext uint `json:"account_sequence_next"` + AccountSequenceAvailable uint32 `json:"account_sequence_available"` + AccountSequenceNext uint32 `json:"account_sequence_next"` Applied bool `json:"applied"` Broadcast bool `json:"broadcast"` Kept bool `json:"kept"` diff --git a/model/client/transactions/submit_test.go b/model/client/transactions/submit_test.go index e0dceb1e..7d744323 100644 --- a/model/client/transactions/submit_test.go +++ b/model/client/transactions/submit_test.go @@ -48,7 +48,7 @@ func TestSubmitResponse(t *testing.T) { TransactionType: "Payment", Fee: types.XRPCurrencyAmount(10000), Sequence: 360, - Flags: types.Uint(2147483648), + Flags: types.SetFlag(2147483648), SigningPubKey: "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB", TxnSignature: "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580", }, diff --git a/model/client/transactions/tx_test.go b/model/client/transactions/tx_test.go index 5b4abb22..673ce041 100644 --- a/model/client/transactions/tx_test.go +++ b/model/client/transactions/tx_test.go @@ -18,7 +18,7 @@ func TestTxResponse(t *testing.T) { TransactionType: transactions.OfferCreateTx, Account: "rhhh49pFH96roGyuC4E5P4CHaNjS1k8gzM", Fee: types.XRPCurrencyAmount(12), - Flags: types.Uint(0), + Flags: types.SetFlag(0), LastLedgerSequence: 56865248, Sequence: 5037710, SigningPubKey: "03B51A3EDF70E4098DA7FB053A01C5A6A0A163A30ED1445F14F87C7C3295FCB3BE", @@ -41,7 +41,7 @@ func TestTxResponse(t *testing.T) { { ModifiedNode: &transactions.ModifiedNode{ FinalFields: &ledger.DirectoryNode{ - Flags: 0, + Flags: types.SetFlag(0), RootIndex: "02BAAC1E67C1CE0E96F0FA2E8061020536CEDD043FEB0FF54F04C66806CF7400", TakerGetsCurrency: "0000000000000000000000000000000000000000", TakerGetsIssuer: "0000000000000000000000000000000000000000", @@ -57,7 +57,7 @@ func TestTxResponse(t *testing.T) { FinalFields: &ledger.AccountRoot{ Account: "rhhh49pFH96roGyuC4E5P4CHaNjS1k8gzM", Balance: types.XRPCurrencyAmount(10404767991), - Flags: 0, + Flags: types.SetFlag(0), OwnerCount: 3, Sequence: 5037711, }, @@ -96,7 +96,7 @@ func TestTxResponse(t *testing.T) { { ModifiedNode: &transactions.ModifiedNode{ FinalFields: &ledger.DirectoryNode{ - Flags: 0, + Flags: types.SetFlag(0), IndexNext: "0000000000000000", IndexPrevious: "0000000000000000", Owner: "rhhh49pFH96roGyuC4E5P4CHaNjS1k8gzM", diff --git a/model/ledger/account_root.go b/model/ledger/account_root.go index b43dcd8e..e41a8439 100644 --- a/model/ledger/account_root.go +++ b/model/ledger/account_root.go @@ -11,16 +11,16 @@ type AccountRoot struct { BurnedNFTokens uint32 `json:",omitempty"` Domain string `json:",omitempty"` EmailHash types.Hash128 `json:",omitempty"` - Flags uint64 + Flags *types.Flag LedgerEntryType LedgerEntryType MessageKey string `json:",omitempty"` MintedNFTokens uint32 `json:",omitempty"` NFTokenMinter types.Address `json:",omitempty"` - OwnerCount uint64 + OwnerCount uint32 PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint64 + PreviousTxnLgrSeq uint32 RegularKey types.Address `json:",omitempty"` - Sequence uint64 + Sequence uint32 TicketCount uint32 `json:",omitempty"` TickSize uint8 `json:",omitempty"` TransferRate uint32 `json:",omitempty"` diff --git a/model/ledger/account_root_test.go b/model/ledger/account_root_test.go index 2a388729..98877fde 100644 --- a/model/ledger/account_root_test.go +++ b/model/ledger/account_root_test.go @@ -14,7 +14,7 @@ func TestAccountRoot(t *testing.T) { Balance: types.XRPCurrencyAmount(148446663), Domain: "6D64756F31332E636F6D", EmailHash: "98B4375E1D753E5B91627516F6D70977", - Flags: 8388608, + Flags: types.SetFlag(8388608), LedgerEntryType: AccountRootEntry, MessageKey: "0000000000000000000000070000000300", OwnerCount: 3, diff --git a/model/ledger/amendments.go b/model/ledger/amendments.go index 815b096b..62779b2b 100644 --- a/model/ledger/amendments.go +++ b/model/ledger/amendments.go @@ -6,7 +6,7 @@ import ( type Amendments struct { Amendments []types.Hash256 `json:",omitempty"` - Flags uint + Flags uint32 LedgerEntryType LedgerEntryType Majorities []MajorityEntry `json:",omitempty"` } diff --git a/model/ledger/check.go b/model/ledger/check.go index 70f28cf8..d2cd35f9 100644 --- a/model/ledger/check.go +++ b/model/ledger/check.go @@ -9,7 +9,7 @@ type Check struct { DestinationNode string `json:",omitempty"` DestinationTag uint `json:",omitempty"` Expiration uint `json:",omitempty"` - Flags uint + Flags uint32 InvoiceID types.Hash256 `json:",omitempty"` LedgerEntryType LedgerEntryType OwnerNode string diff --git a/model/ledger/deposit_preauth.go b/model/ledger/deposit_preauth.go index 42fb10bd..45f9e22d 100644 --- a/model/ledger/deposit_preauth.go +++ b/model/ledger/deposit_preauth.go @@ -7,11 +7,11 @@ import ( type DepositPreauthObj struct { Account types.Address Authorize types.Address - Flags uint + Flags uint32 LedgerEntryType LedgerEntryType OwnerNode string PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint + PreviousTxnLgrSeq uint32 } func (*DepositPreauthObj) EntryType() LedgerEntryType { diff --git a/model/ledger/directory_node.go b/model/ledger/directory_node.go index bf90a2b2..bfc7d1d9 100644 --- a/model/ledger/directory_node.go +++ b/model/ledger/directory_node.go @@ -5,7 +5,7 @@ import ( ) type DirectoryNode struct { - Flags uint + Flags *types.Flag Indexes []types.Hash256 IndexNext string `json:",omitempty"` IndexPrevious string `json:",omitempty"` diff --git a/model/ledger/directory_node_test.go b/model/ledger/directory_node_test.go index 2a6f1769..a2d96314 100644 --- a/model/ledger/directory_node_test.go +++ b/model/ledger/directory_node_test.go @@ -9,7 +9,7 @@ import ( func TestOfferDirectoryNode(t *testing.T) { var s LedgerObject = &DirectoryNode{ - Flags: 0, + Flags: types.SetFlag(0), Indexes: []types.Hash256{ "AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD", }, @@ -41,7 +41,7 @@ func TestOfferDirectoryNode(t *testing.T) { func TestOwnerDirectoryNode(t *testing.T) { var s LedgerObject = &DirectoryNode{ - Flags: 0, + Flags: types.SetFlag(0), Indexes: []types.Hash256{ "AD7EAE148287EF12D213A251015F86E6D4BD34B3C4A0A1ED9A17198373F908AD", "E83BBB58949A8303DF07172B16FB8EFBA66B9191F3836EC27A4568ED5997BAC5", diff --git a/model/ledger/escrow.go b/model/ledger/escrow.go index 5d2c760a..1e7dc635 100644 --- a/model/ledger/escrow.go +++ b/model/ledger/escrow.go @@ -13,11 +13,11 @@ type Escrow struct { DestinationNode string `json:",omitempty"` DestinationTag uint `json:",omitempty"` FinishAfter uint `json:",omitempty"` - Flags uint + Flags uint32 LedgerEntryType LedgerEntryType OwnerNode string PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint + PreviousTxnLgrSeq uint32 SourceTag uint `json:",omitempty"` } diff --git a/model/ledger/fee_settings.go b/model/ledger/fee_settings.go index ea0b58e5..0e63c36d 100644 --- a/model/ledger/fee_settings.go +++ b/model/ledger/fee_settings.go @@ -2,7 +2,7 @@ package ledger type FeeSettings struct { BaseFee string - Flags uint + Flags uint32 LedgerEntryType LedgerEntryType ReferenceFeeUnits uint ReserveBase uint diff --git a/model/ledger/ledger_hashes.go b/model/ledger/ledger_hashes.go index 45e5b9b6..c00dd264 100644 --- a/model/ledger/ledger_hashes.go +++ b/model/ledger/ledger_hashes.go @@ -3,10 +3,10 @@ package ledger import "github.com/CreatureDev/xrpl-go/model/transactions/types" type LedgerHashes struct { - FirstLedgerSequence uint - Flags uint + FirstLedgerSequence uint32 + Flags uint32 Hashes []types.Hash256 - LastLedgerSequence uint + LastLedgerSequence uint32 LedgerEntryType LedgerEntryType } diff --git a/model/ledger/negative_unl.go b/model/ledger/negative_unl.go index 07a1b5d0..c02e2726 100644 --- a/model/ledger/negative_unl.go +++ b/model/ledger/negative_unl.go @@ -2,7 +2,7 @@ package ledger type NegativeUNL struct { DisabledValidators []DisabledValidatorEntry `json:",omitempty"` - Flags uint + Flags uint32 LedgerEntryType LedgerEntryType ValidatorToDisable string `json:",omitempty"` ValidatorToReEnable string `json:",omitempty"` @@ -17,6 +17,6 @@ type DisabledValidatorEntry struct { } type DisabledValidator struct { - FirstLedgerSequence uint + FirstLedgerSequence uint32 PublicKey string } diff --git a/model/ledger/nftoken_offer.go b/model/ledger/nftoken_offer.go index 66d2079f..fbb8bfcf 100644 --- a/model/ledger/nftoken_offer.go +++ b/model/ledger/nftoken_offer.go @@ -10,14 +10,14 @@ type NFTokenOffer struct { Amount types.CurrencyAmount Destination types.Address `json:",omitempty"` Expiration uint `json:",omitempty"` - Flags uint + Flags uint32 LedgerEntryType LedgerEntryType NFTokenID types.Hash256 NFTokenOfferNode string `json:",omitempty"` Owner types.Address OwnerNode string `json:",omitempty"` PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint + PreviousTxnLgrSeq uint32 } func (*NFTokenOffer) EntryType() LedgerEntryType { @@ -30,14 +30,14 @@ func (n *NFTokenOffer) UnmarshalJSON(data []byte) error { Amount json.RawMessage Destination types.Address Expiration uint - Flags uint + Flags uint32 LedgerEntryType LedgerEntryType NFTokenID types.Hash256 NFTokenOfferNode string Owner types.Address OwnerNode string PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint + PreviousTxnLgrSeq uint32 } var h nftHelper if err := json.Unmarshal(data, &h); err != nil { diff --git a/model/ledger/nftoken_page.go b/model/ledger/nftoken_page.go index daa59959..ea603dc4 100644 --- a/model/ledger/nftoken_page.go +++ b/model/ledger/nftoken_page.go @@ -7,7 +7,7 @@ type NFTokenPage struct { NextPageMin types.Hash256 `json:",omitempty"` PreviousPageMin types.Hash256 `json:",omitempty"` PreviousTxnID types.Hash256 `json:",omitempty"` - PreviousTxnLgrSeq uint `json:",omitempty"` + PreviousTxnLgrSeq uint32 `json:",omitempty"` NFTokens []types.NFToken } diff --git a/model/ledger/offer.go b/model/ledger/offer.go index 95a83f63..7c068f89 100644 --- a/model/ledger/offer.go +++ b/model/ledger/offer.go @@ -6,7 +6,11 @@ import ( "github.com/CreatureDev/xrpl-go/model/transactions/types" ) -type OfferFlags uint +type OfferFlags uint32 + +func (f OfferFlags) ToUint() uint32 { + return uint32(f) +} const ( PassiveOffer OfferFlags = 0x00010000 @@ -19,11 +23,11 @@ type Offer struct { BookNode string Expiration uint `json:",omitempty"` Flags OfferFlags - LedgerEntryType LedgerEntryType + LedgerEntryType LedgerEntryType `json:",omitempty"` OwnerNode string PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint - Sequence uint + PreviousTxnLgrSeq uint32 + Sequence uint32 TakerPays types.CurrencyAmount TakerGets types.CurrencyAmount } @@ -42,8 +46,8 @@ func (o *Offer) UnmarshalJSON(data []byte) error { LedgerEntryType LedgerEntryType OwnerNode string PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint - Sequence uint + PreviousTxnLgrSeq uint32 + Sequence uint32 TakerPays json.RawMessage TakerGets json.RawMessage } diff --git a/model/ledger/pay_channel.go b/model/ledger/pay_channel.go index fdf188a9..122259a1 100644 --- a/model/ledger/pay_channel.go +++ b/model/ledger/pay_channel.go @@ -11,11 +11,11 @@ type PayChannel struct { DestinationTag uint `json:",omitempty"` DestinationNode string `json:",omitempty"` Expiration uint `json:",omitempty"` - Flags uint + Flags uint32 LedgerEntryType LedgerEntryType OwnerNode string PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint + PreviousTxnLgrSeq uint32 PublicKey string SettleDelay uint SourceTag uint `json:",omitempty"` diff --git a/model/ledger/ripple_state.go b/model/ledger/ripple_state.go index f9e3061b..f4f90c58 100644 --- a/model/ledger/ripple_state.go +++ b/model/ledger/ripple_state.go @@ -17,7 +17,7 @@ type RippleState struct { LowQualityIn uint `json:",omitempty"` LowQualityOut uint `json:",omitempty"` PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint + PreviousTxnLgrSeq uint32 } func (*RippleState) EntryType() LedgerEntryType { diff --git a/model/ledger/signer_list.go b/model/ledger/signer_list.go index 4bb28058..e8c7e5ac 100644 --- a/model/ledger/signer_list.go +++ b/model/ledger/signer_list.go @@ -8,11 +8,15 @@ const ( LsfOneOwnerCount SignerListFlags = 0x00010000 ) +func (f SignerListFlags) ToUint() uint32 { + return uint32(f) +} + type SignerList struct { LedgerEntryType LedgerEntryType Flags SignerListFlags PreviousTxnID string - PreviousTxnLgrSeq uint64 + PreviousTxnLgrSeq uint32 OwnerNode string SignerEntries []SignerEntryWrapper SignerListID uint64 diff --git a/model/ledger/ticket.go b/model/ledger/ticket.go index 02f0083c..770515c4 100644 --- a/model/ledger/ticket.go +++ b/model/ledger/ticket.go @@ -4,12 +4,12 @@ import "github.com/CreatureDev/xrpl-go/model/transactions/types" type Ticket struct { Account types.Address - Flags uint + Flags uint32 LedgerEntryType LedgerEntryType OwnerNode string PreviousTxnID types.Hash256 - PreviousTxnLgrSeq uint - TicketSequence uint + PreviousTxnLgrSeq uint32 + TicketSequence uint32 } func (*Ticket) EntryType() LedgerEntryType { diff --git a/model/transactions/account_set.go b/model/transactions/account_set.go index 8f1fc3e5..91ef1afe 100644 --- a/model/transactions/account_set.go +++ b/model/transactions/account_set.go @@ -6,16 +6,16 @@ import ( type AccountSet struct { BaseTx - ClearFlag uint `json:",omitempty"` + ClearFlag uint32 `json:",omitempty"` Domain string `json:",omitempty"` EmailHash types.Hash128 `json:",omitempty"` MessageKey string `json:",omitempty"` NFTokenMinter string `json:",omitempty"` - SetFlag uint `json:",omitempty"` + SetFlag uint32 `json:",omitempty"` TransferRate uint `json:",omitempty"` TickSize uint8 `json:",omitempty"` WalletLocator types.Hash256 `json:",omitempty"` - WalletSize uint `json:",omitempty"` + WalletSize uint32 `json:",omitempty"` } func (*AccountSet) TxType() TxType { diff --git a/model/transactions/escrow_cancel.go b/model/transactions/escrow_cancel.go index b535a544..bc37de93 100644 --- a/model/transactions/escrow_cancel.go +++ b/model/transactions/escrow_cancel.go @@ -7,7 +7,7 @@ import ( type EscrowCancel struct { BaseTx Owner types.Address - OfferSequence uint + OfferSequence uint32 } func (*EscrowCancel) TxType() TxType { diff --git a/model/transactions/escrow_finish.go b/model/transactions/escrow_finish.go index 74deeddf..720d2b29 100644 --- a/model/transactions/escrow_finish.go +++ b/model/transactions/escrow_finish.go @@ -7,7 +7,7 @@ import ( type EscrowFinish struct { BaseTx `mapstructure:",squash"` Owner types.Address - OfferSequence uint + OfferSequence uint32 Condition string `json:",omitempty"` Fulfillment string `json:",omitempty"` } diff --git a/model/transactions/nftoken_create_offer_test.go b/model/transactions/nftoken_create_offer_test.go index 5177c32e..1e7b0a1d 100644 --- a/model/transactions/nftoken_create_offer_test.go +++ b/model/transactions/nftoken_create_offer_test.go @@ -14,7 +14,7 @@ func TestNFTokenCreateOfferTx(t *testing.T) { BaseTx: BaseTx{ Account: "rs8jBmmfpwgmrSPgwMsh7CvKRmRt1JTVSX", TransactionType: NFTokenCreateOfferTx, - Flags: types.Uint(1), + Flags: types.SetFlag(1), }, NFTokenID: "000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007", Amount: types.XRPCurrencyAmount(1000000), diff --git a/model/transactions/nftoken_mint_test.go b/model/transactions/nftoken_mint_test.go index d908531c..6b8ee032 100644 --- a/model/transactions/nftoken_mint_test.go +++ b/model/transactions/nftoken_mint_test.go @@ -15,7 +15,7 @@ func TestNFTokenMintTx(t *testing.T) { Account: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", TransactionType: NFTokenMintTx, Fee: types.XRPCurrencyAmount(10), - Flags: types.Uint(8), + Flags: types.SetFlag(8), Memos: []MemoWrapper{ { Memo: Memo{ diff --git a/model/transactions/offer_cancel.go b/model/transactions/offer_cancel.go index db5fb80c..8068ce15 100644 --- a/model/transactions/offer_cancel.go +++ b/model/transactions/offer_cancel.go @@ -2,7 +2,7 @@ package transactions type OfferCancel struct { BaseTx - OfferSequence uint + OfferSequence uint32 } func (*OfferCancel) TxType() TxType { diff --git a/model/transactions/offer_create.go b/model/transactions/offer_create.go index fd4f603c..81edfa39 100644 --- a/model/transactions/offer_create.go +++ b/model/transactions/offer_create.go @@ -8,8 +8,8 @@ import ( type OfferCreate struct { BaseTx - Expiration uint `json:",omitempty"` - OfferSequence uint `json:",omitempty"` + Expiration uint `json:",omitempty"` + OfferSequence uint32 `json:",omitempty"` TakerGets types.CurrencyAmount TakerPays types.CurrencyAmount } @@ -21,8 +21,8 @@ func (*OfferCreate) TxType() TxType { func (o *OfferCreate) UnmarshalJSON(data []byte) error { type ocHelper struct { BaseTx - Expiration uint `json:",omitempty"` - OfferSequence uint `json:",omitempty"` + Expiration uint `json:",omitempty"` + OfferSequence uint32 `json:",omitempty"` TakerGets json.RawMessage TakerPays json.RawMessage } diff --git a/model/transactions/payment_test.go b/model/transactions/payment_test.go index 8a0f78e0..0bdaa504 100644 --- a/model/transactions/payment_test.go +++ b/model/transactions/payment_test.go @@ -15,7 +15,7 @@ func TestPaymentTx(t *testing.T) { Account: "abc", TransactionType: PaymentTx, Fee: types.XRPCurrencyAmount(1000), - Flags: types.Uint(262144), + Flags: types.SetFlag(262144), }, Amount: types.IssuedCurrencyAmount{ Issuer: "def", diff --git a/model/transactions/transaction_metadata.go b/model/transactions/transaction_metadata.go index ee090e73..abc3f2ef 100644 --- a/model/transactions/transaction_metadata.go +++ b/model/transactions/transaction_metadata.go @@ -125,7 +125,7 @@ type ModifiedNode struct { FinalFields ledger.LedgerObject `json:"FinalFields,omitempty"` PreviousFields ledger.LedgerObject `json:"PreviousFields,omitempty"` PreviousTxnID string `json:"PreviousTxnID,omitempty"` - PreviousTxnLgrSeq uint64 `json:"PreviousTxnLgrSeq,omitempty"` + PreviousTxnLgrSeq uint32 `json:"PreviousTxnLgrSeq,omitempty"` } func (n *ModifiedNode) UnmarshalJSON(data []byte) error { @@ -135,7 +135,7 @@ func (n *ModifiedNode) UnmarshalJSON(data []byte) error { FinalFields json.RawMessage PreviousFields json.RawMessage PreviousTxnID string - PreviousTxnLgrSeq uint64 + PreviousTxnLgrSeq uint32 } err := json.Unmarshal(data, &h) if err != nil { diff --git a/model/transactions/trust_set_test.go b/model/transactions/trust_set_test.go index 62a4c329..5e535670 100644 --- a/model/transactions/trust_set_test.go +++ b/model/transactions/trust_set_test.go @@ -15,7 +15,7 @@ func TestTrustSetTx(t *testing.T) { Account: "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", TransactionType: TrustSetTx, Fee: types.XRPCurrencyAmount(12), - Flags: types.Uint(262144), + Flags: types.SetFlag(262144), Sequence: 12, LastLedgerSequence: 8007750, }, diff --git a/model/transactions/tx.go b/model/transactions/tx.go index 5f46a235..27a65106 100644 --- a/model/transactions/tx.go +++ b/model/transactions/tx.go @@ -29,15 +29,15 @@ type BaseTx struct { Account types.Address TransactionType TxType Fee types.XRPCurrencyAmount `json:",omitempty"` - Sequence uint `json:",omitempty"` + Sequence uint32 `json:",omitempty"` AccountTxnID types.Hash256 `json:",omitempty"` - Flags *uint `json:",omitempty"` - LastLedgerSequence uint `json:",omitempty"` + Flags *types.Flag `json:",omitempty"` + LastLedgerSequence uint32 `json:",omitempty"` Memos []MemoWrapper `json:",omitempty"` Signers []Signer `json:",omitempty"` SourceTag uint `json:",omitempty"` SigningPubKey string `json:",omitempty"` - TicketSequence uint `json:",omitempty"` + TicketSequence uint32 `json:",omitempty"` TxnSignature string `json:",omitempty"` } diff --git a/model/transactions/types/flags.go b/model/transactions/types/flags.go new file mode 100644 index 00000000..8a0e2415 --- /dev/null +++ b/model/transactions/types/flags.go @@ -0,0 +1,20 @@ +package types + +// FlagsI is an interface for types that can be converted to a uint. +type FlagsI interface { + ToUint() uint32 +} + +type Flag uint32 + +func (f *Flag) ToUint() uint32 { + return uint32(*f) +} + +// SetFlag is a helper function that allocates a new uint value +// to store v and returns a pointer to it. +func SetFlag(v uint32) *Flag { + p := new(uint32) + *p = v + return (*Flag)(p) +} diff --git a/model/transactions/types/uint.go b/model/transactions/types/uint.go deleted file mode 100644 index 2068232f..00000000 --- a/model/transactions/types/uint.go +++ /dev/null @@ -1,9 +0,0 @@ -package types - -// Uint is a helper function that allocates a new uint value -// to store v and returns a pointer to it. -func Uint(v uint) *uint { - p := new(uint) - *p = v - return p -} From 4e84c19efb7e58a57ec83066ef3717daaf735226 Mon Sep 17 00:00:00 2001 From: JCrawsh Date: Tue, 14 Nov 2023 18:27:26 +0000 Subject: [PATCH 25/32] chore: updated definitions.json --- binary-codec/definitions/definitions.json | 1775 +++++++++++++++------ 1 file changed, 1324 insertions(+), 451 deletions(-) diff --git a/binary-codec/definitions/definitions.json b/binary-codec/definitions/definitions.json index f3d92f77..b6b48f44 100644 --- a/binary-codec/definitions/definitions.json +++ b/binary-codec/definitions/definitions.json @@ -1,29 +1,34 @@ { "TYPES": { - "Validation": 10003, "Done": -1, + "Unknown": -2, + "NotPresent": 0, + "UInt16": 1, + "UInt32": 2, + "UInt64": 3, "Hash128": 4, + "Hash256": 5, + "Amount": 6, "Blob": 7, "AccountID": 8, - "Amount": 6, - "Hash256": 5, - "UInt8": 16, - "Vector256": 19, "STObject": 14, - "Unknown": -2, - "Transaction": 10001, + "STArray": 15, + "UInt8": 16, "Hash160": 17, "PathSet": 18, + "Vector256": 19, + "UInt96": 20, + "UInt192": 21, + "UInt384": 22, + "UInt512": 23, + "Issue": 24, + "XChainBridge": 25, + "Transaction": 10001, "LedgerEntry": 10002, - "UInt16": 1, - "NotPresent": 0, - "UInt64": 3, - "UInt32": 2, - "STArray": 15 + "Validation": 10003, + "Metadata": 10004 }, "LEDGER_ENTRY_TYPES": { - "Any": -3, - "Child": -2, "Invalid": -1, "AccountRoot": 97, "DirectoryNode": 100, @@ -31,18 +36,25 @@ "Ticket": 84, "SignerList": 83, "Offer": 111, + "Bridge": 105, "LedgerHashes": 104, "Amendments": 102, + "XChainOwnedClaimID": 113, + "XChainOwnedCreateAccountClaimID": 116, "FeeSettings": 115, "Escrow": 117, "PayChannel": 120, - "DepositPreauth": 112, "Check": 67, - "Nickname": 110, - "Contract": 99, + "DepositPreauth": 112, + "NegativeUNL": 78, "NFTokenPage": 80, "NFTokenOffer": 55, - "NegativeUNL": 78 + "AMM": 121, + "Any": -3, + "Child": -2, + "Nickname": 110, + "Contract": 99, + "GeneratorMap": 103 }, "FIELDS": [ [ @@ -65,6 +77,176 @@ "type": "Unknown" } ], + [ + "ObjectEndMarker", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "ArrayEndMarker", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } + ], + [ + "hash", + { + "nth": 257, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": false, + "type": "Hash256" + } + ], + [ + "index", + { + "nth": 258, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": false, + "type": "Hash256" + } + ], + [ + "taker_gets_funded", + { + "nth": 258, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": false, + "type": "Amount" + } + ], + [ + "taker_pays_funded", + { + "nth": 259, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": false, + "type": "Amount" + } + ], + [ + "LedgerEntry", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": true, + "type": "LedgerEntry" + } + ], + [ + "Transaction", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": true, + "type": "Transaction" + } + ], + [ + "Validation", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": true, + "type": "Validation" + } + ], + [ + "Metadata", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Metadata" + } + ], + [ + "CloseResolution", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "Method", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "TransactionResult", + { + "nth": 3, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "TickSize", + { + "nth": 16, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "UNLModifyDisabling", + { + "nth": 17, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "HookResult", + { + "nth": 18, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "WasLockingChainSend", + { + "nth": 19, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], [ "LedgerEntryType", { @@ -106,79 +288,79 @@ } ], [ - "Flags", + "TradingFee", { - "nth": 2, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "SourceTag", + "DiscountedFee", { - "nth": 3, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "Sequence", + "Version", { - "nth": 4, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "PreviousTxnLgrSeq", + "HookStateChangeCount", { - "nth": 5, + "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "LedgerSequence", + "HookEmitCount", { - "nth": 6, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "CloseTime", + "HookExecutionIndex", { - "nth": 7, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "ParentCloseTime", + "HookApiVersion", { - "nth": 8, + "nth": 20, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "SigningTime", + "NetworkID", { - "nth": 9, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -186,9 +368,9 @@ } ], [ - "Expiration", + "Flags", { - "nth": 10, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -196,9 +378,9 @@ } ], [ - "TransferRate", + "SourceTag", { - "nth": 11, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -206,9 +388,9 @@ } ], [ - "WalletSize", + "Sequence", { - "nth": 12, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -216,9 +398,9 @@ } ], [ - "OwnerCount", + "PreviousTxnLgrSeq", { - "nth": 13, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -226,329 +408,919 @@ } ], [ - "DestinationTag", + "LedgerSequence", + { + "nth": 6, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "CloseTime", + { + "nth": 7, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "ParentCloseTime", + { + "nth": 8, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "SigningTime", + { + "nth": 9, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "Expiration", + { + "nth": 10, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "TransferRate", + { + "nth": 11, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "WalletSize", + { + "nth": 12, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "OwnerCount", + { + "nth": 13, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "DestinationTag", + { + "nth": 14, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "HighQualityIn", + { + "nth": 16, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "HighQualityOut", + { + "nth": 17, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "LowQualityIn", + { + "nth": 18, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "LowQualityOut", + { + "nth": 19, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "QualityIn", + { + "nth": 20, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "QualityOut", + { + "nth": 21, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "StampEscrow", + { + "nth": 22, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "BondAmount", + { + "nth": 23, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "LoadFee", + { + "nth": 24, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "OfferSequence", + { + "nth": 25, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "FirstLedgerSequence", + { + "nth": 26, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "LastLedgerSequence", + { + "nth": 27, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "TransactionIndex", + { + "nth": 28, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "OperationLimit", + { + "nth": 29, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "ReferenceFeeUnits", + { + "nth": 30, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "ReserveBase", + { + "nth": 31, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "ReserveIncrement", + { + "nth": 32, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "SetFlag", + { + "nth": 33, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "ClearFlag", + { + "nth": 34, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "SignerQuorum", + { + "nth": 35, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "CancelAfter", + { + "nth": 36, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "FinishAfter", + { + "nth": 37, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "SignerListID", + { + "nth": 38, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "SettleDelay", + { + "nth": 39, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "TicketCount", + { + "nth": 40, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "TicketSequence", + { + "nth": 41, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "NFTokenTaxon", + { + "nth": 42, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "MintedNFTokens", + { + "nth": 43, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "BurnedNFTokens", + { + "nth": 44, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "HookStateCount", + { + "nth": 45, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "EmitGeneration", + { + "nth": 46, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "VoteWeight", + { + "nth": 48, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "FirstNFTokenSequence", + { + "nth": 50, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "IndexNext", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "IndexPrevious", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "BookNode", + { + "nth": 3, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "OwnerNode", + { + "nth": 4, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "BaseFee", + { + "nth": 5, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "ExchangeRate", + { + "nth": 6, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "LowNode", + { + "nth": 7, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HighNode", + { + "nth": 8, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "DestinationNode", + { + "nth": 9, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "Cookie", + { + "nth": 10, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "ServerVersion", + { + "nth": 11, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "NFTokenOfferNode", + { + "nth": 12, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "EmitBurden", + { + "nth": 13, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HookOn", + { + "nth": 16, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HookInstructionCount", + { + "nth": 17, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HookReturnCode", + { + "nth": 18, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "ReferenceCount", + { + "nth": 19, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "XChainClaimID", { - "nth": 14, + "nth": 20, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt64" } ], [ - "HighQualityIn", + "XChainAccountCreateCount", { - "nth": 16, + "nth": 21, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt64" } ], [ - "HighQualityOut", + "XChainAccountClaimCount", { - "nth": 17, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt64" } ], [ - "LowQualityIn", + "EmailHash", { - "nth": 18, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash128" } ], [ - "LowQualityOut", + "TakerPaysCurrency", { - "nth": 19, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash160" } ], [ - "QualityIn", + "TakerPaysIssuer", { - "nth": 20, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash160" } ], [ - "QualityOut", + "TakerGetsCurrency", { - "nth": 21, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash160" } ], [ - "StampEscrow", + "TakerGetsIssuer", { - "nth": 22, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash160" } ], [ - "BondAmount", + "LedgerHash", { - "nth": 23, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "LoadFee", + "ParentHash", { - "nth": 24, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "OfferSequence", + "TransactionHash", { - "nth": 25, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "FirstLedgerSequence", + "AccountHash", { - "nth": 26, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "LastLedgerSequence", + "PreviousTxnID", { - "nth": 27, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "TransactionIndex", + "LedgerIndex", { - "nth": 28, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "OperationLimit", + "WalletLocator", { - "nth": 29, + "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "ReferenceFeeUnits", + "RootIndex", { - "nth": 30, + "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "ReserveBase", + "AccountTxnID", { - "nth": 31, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "ReserveIncrement", + "NFTokenID", { - "nth": 32, + "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "SetFlag", + "EmitParentTxnID", { - "nth": 33, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "ClearFlag", + "EmitNonce", { - "nth": 34, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "SignerQuorum", + "EmitHookHash", { - "nth": 35, + "nth": 13, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "CancelAfter", + "AMMID", { - "nth": 36, + "nth": 14, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "FinishAfter", + "BookDirectory", { - "nth": 37, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Hash256" } ], [ - "IndexNext", + "InvoiceID", { - "nth": 1, + "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "IndexPrevious", + "Nickname", { - "nth": 2, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "BookNode", + "Amendment", { - "nth": 3, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "OwnerNode", + "Digest", { - "nth": 4, + "nth": 21, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "BaseFee", + "Channel", { - "nth": 5, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "ExchangeRate", + "ConsensusHash", { - "nth": 6, + "nth": 23, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "LowNode", + "CheckID", { - "nth": 7, + "nth": 24, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "HighNode", + "ValidatedHash", { - "nth": 8, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "EmailHash", + "PreviousPageMin", { - "nth": 1, + "nth": 26, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash128" + "type": "Hash256" } ], [ - "LedgerHash", + "NextPageMin", { - "nth": 1, + "nth": 27, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -556,9 +1328,9 @@ } ], [ - "ParentHash", + "NFTokenBuyOffer", { - "nth": 2, + "nth": 28, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -566,9 +1338,9 @@ } ], [ - "TransactionHash", + "NFTokenSellOffer", { - "nth": 3, + "nth": 29, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -576,9 +1348,9 @@ } ], [ - "AccountHash", + "HookStateKey", { - "nth": 4, + "nth": 30, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -586,9 +1358,9 @@ } ], [ - "PreviousTxnID", + "HookHash", { - "nth": 5, + "nth": 31, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -596,9 +1368,9 @@ } ], [ - "LedgerIndex", + "HookNamespace", { - "nth": 6, + "nth": 32, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -606,9 +1378,9 @@ } ], [ - "WalletLocator", + "HookSetTxnID", { - "nth": 7, + "nth": 33, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -616,119 +1388,119 @@ } ], [ - "RootIndex", + "Amount", { - "nth": 8, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "Amount" } ], [ - "AccountTxnID", + "Balance", { - "nth": 9, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "Amount" } ], [ - "NFTokenID", + "LimitAmount", { - "nth": 10, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "Amount" } ], [ - "BookDirectory", + "TakerPays", { - "nth": 16, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "Amount" } ], [ - "InvoiceID", + "TakerGets", { - "nth": 17, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "Amount" } ], [ - "Nickname", + "LowLimit", { - "nth": 18, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "Amount" } ], [ - "Amendment", + "HighLimit", { - "nth": 19, + "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "Amount" } ], [ - "TicketID", + "Fee", { - "nth": 20, + "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "Amount" } ], [ - "Digest", + "SendMax", { - "nth": 21, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "Amount" } ], [ - "hash", + "DeliverMin", { - "nth": 257, + "nth": 10, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Hash256" + "isSerialized": true, + "isSigningField": true, + "type": "Amount" } ], [ - "index", + "Amount2", { - "nth": 258, + "nth": 11, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Hash256" + "isSerialized": true, + "isSigningField": true, + "type": "Amount" } ], [ - "Amount", + "BidMin", { - "nth": 1, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -736,9 +1508,9 @@ } ], [ - "Balance", + "BidMax", { - "nth": 2, + "nth": 13, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -746,9 +1518,9 @@ } ], [ - "LimitAmount", + "MinimumOffer", { - "nth": 3, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -756,9 +1528,9 @@ } ], [ - "TakerPays", + "RippleEscrow", { - "nth": 4, + "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -766,9 +1538,9 @@ } ], [ - "TakerGets", + "DeliveredAmount", { - "nth": 5, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -776,9 +1548,9 @@ } ], [ - "LowLimit", + "NFTokenBrokerFee", { - "nth": 6, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -786,9 +1558,9 @@ } ], [ - "HighLimit", + "BaseFeeDrops", { - "nth": 7, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -796,9 +1568,9 @@ } ], [ - "Fee", + "ReserveBaseDrops", { - "nth": 8, + "nth": 23, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -806,9 +1578,9 @@ } ], [ - "SendMax", + "ReserveIncrementDrops", { - "nth": 9, + "nth": 24, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -816,9 +1588,9 @@ } ], [ - "DeliverMin", + "LPTokenOut", { - "nth": 10, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -826,9 +1598,9 @@ } ], [ - "MinimumOffer", + "LPTokenIn", { - "nth": 16, + "nth": 26, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -836,9 +1608,9 @@ } ], [ - "RippleEscrow", + "EPrice", { - "nth": 17, + "nth": 27, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -846,9 +1618,9 @@ } ], [ - "DeliveredAmount", + "Price", { - "nth": 18, + "nth": 28, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -856,9 +1628,9 @@ } ], [ - "NFTokenBrokerFee", + "SignatureReward", { - "nth": 19, + "nth": 29, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -866,22 +1638,22 @@ } ], [ - "taker_gets_funded", + "MinAccountCreateAmount", { - "nth": 258, + "nth": 30, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, "type": "Amount" } ], [ - "taker_pays_funded", + "LPTokenBalance", { - "nth": 259, + "nth": 31, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, "type": "Amount" } ], @@ -1085,6 +1857,46 @@ "type": "Blob" } ], + [ + "HookStateData", + { + "nth": 22, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "Blob" + } + ], + [ + "HookReturnString", + { + "nth": 23, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "Blob" + } + ], + [ + "HookParameterName", + { + "nth": 24, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "Blob" + } + ], + [ + "HookParameterValue", + { + "nth": 25, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "Blob" + } + ], [ "Account", { @@ -1146,9 +1958,9 @@ } ], [ - "Target", + "RegularKey", { - "nth": 7, + "nth": 8, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1156,9 +1968,9 @@ } ], [ - "RegularKey", + "NFTokenMinter", { - "nth": 8, + "nth": 9, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1166,9 +1978,9 @@ } ], [ - "NFTokenMinter", + "EmitCallback", { - "nth": 9, + "nth": 10, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1176,623 +1988,633 @@ } ], [ - "ObjectEndMarker", + "HookAccount", { - "nth": 1, - "isVLEncoded": false, + "nth": 16, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "TransactionMetaData", + "OtherChainSource", { - "nth": 2, - "isVLEncoded": false, + "nth": 18, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "CreatedNode", + "OtherChainDestination", { - "nth": 3, - "isVLEncoded": false, + "nth": 19, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "DeletedNode", + "AttestationSignerAccount", { - "nth": 4, - "isVLEncoded": false, + "nth": 20, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "ModifiedNode", + "AttestationRewardAccount", { - "nth": 5, - "isVLEncoded": false, + "nth": 21, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "PreviousFields", + "LockingChainDoor", { - "nth": 6, - "isVLEncoded": false, + "nth": 22, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "FinalFields", + "IssuingChainDoor", { - "nth": 7, - "isVLEncoded": false, + "nth": 23, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "NewFields", + "Indexes", { - "nth": 8, - "isVLEncoded": false, + "nth": 1, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "Vector256" } ], [ - "TemplateEntry", + "Hashes", { - "nth": 9, - "isVLEncoded": false, + "nth": 2, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "Vector256" } ], [ - "Memo", + "Amendments", { - "nth": 10, - "isVLEncoded": false, + "nth": 3, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "Vector256" } ], [ - "SignerEntry", + "NFTokenOffers", { - "nth": 11, + "nth": 4, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "Vector256" + } + ], + [ + "Paths", + { + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "PathSet" } ], [ - "NFToken", + "LockingChainIssue", { - "nth": 12, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "Issue" } ], [ - "Signer", + "IssuingChainIssue", { - "nth": 16, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "Issue" } ], [ - "Majority", + "Asset", { - "nth": 18, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "Issue" } ], [ - "DisabledValidator", + "Asset2", { - "nth": 19, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "Issue" } ], [ - "ArrayEndMarker", + "XChainBridge", { "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "XChainBridge" } ], [ - "Signers", + "TransactionMetaData", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "CreatedNode", { "nth": 3, "isVLEncoded": false, "isSerialized": true, - "isSigningField": false, - "type": "STArray" + "isSigningField": true, + "type": "STObject" } ], [ - "SignerEntries", + "DeletedNode", { "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "Template", + "ModifiedNode", { "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "Necessary", + "PreviousFields", { "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "Sufficient", + "FinalFields", { "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "AffectedNodes", + "NewFields", { "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "Memos", + "TemplateEntry", { "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "NFTokens", + "Memo", { "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "Majorities", + "SignerEntry", { - "nth": 16, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "DisabledValidators", + "NFToken", { - "nth": 17, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "CloseResolution", + "EmitDetails", { - "nth": 1, + "nth": 13, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STObject" } ], [ - "Method", + "Hook", { - "nth": 2, + "nth": 14, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STObject" } ], [ - "TransactionResult", + "Signer", { - "nth": 3, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STObject" } ], [ - "TakerPaysCurrency", + "Majority", { - "nth": 1, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "TakerPaysIssuer", + "DisabledValidator", { - "nth": 2, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "TakerGetsCurrency", + "EmittedTxn", { - "nth": 3, + "nth": 20, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "TakerGetsIssuer", + "HookExecution", { - "nth": 4, + "nth": 21, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "Paths", + "HookDefinition", { - "nth": 1, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "PathSet" + "type": "STObject" } ], [ - "Indexes", + "HookParameter", { - "nth": 1, - "isVLEncoded": true, + "nth": 23, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "Hashes", + "HookGrant", { - "nth": 2, - "isVLEncoded": true, + "nth": 24, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "Amendments", + "VoteEntry", { - "nth": 3, - "isVLEncoded": true, + "nth": 25, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "NFTokenOffers", + "AuctionSlot", { - "nth": 4, - "isVLEncoded": true, + "nth": 26, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" - } - ], - [ - "Transaction", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Transaction" + "type": "STObject" } ], [ - "LedgerEntry", + "AuthAccount", { - "nth": 1, + "nth": 27, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "LedgerEntry" + "isSerialized": true, + "isSigningField": true, + "type": "STObject" } ], [ - "Validation", + "XChainClaimProofSig", { - "nth": 1, + "nth": 28, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Validation" + "isSerialized": true, + "isSigningField": true, + "type": "STObject" } ], [ - "SignerListID", + "XChainCreateAccountProofSig", { - "nth": 38, + "nth": 29, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "SettleDelay", + "XChainClaimAttestationCollectionElement", { - "nth": 39, + "nth": 30, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "TicketCount", + "XChainCreateAccountAttestationCollectionElement", { - "nth": 40, + "nth": 31, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "TicketSequence", + "Signers", { - "nth": 41, + "nth": 3, "isVLEncoded": false, "isSerialized": true, - "isSigningField": true, - "type": "UInt32" + "isSigningField": false, + "type": "STArray" } ], [ - "NFTokenTaxon", + "SignerEntries", { - "nth": 42, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STArray" } ], [ - "MintedNFTokens", + "Template", { - "nth": 43, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STArray" } ], [ - "BurnedNFTokens", + "Necessary", { - "nth": 44, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STArray" } ], [ - "Channel", + "Sufficient", { - "nth": 22, + "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "ConsensusHash", + "AffectedNodes", { - "nth": 23, + "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "CheckID", + "Memos", { - "nth": 24, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "ValidatedHash", + "NFTokens", { - "nth": 25, + "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "PreviousPageMin", + "Hooks", { - "nth": 26, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "NextPageMin", + "VoteSlots", { - "nth": 27, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "NFTokenBuyOffer", + "Majorities", { - "nth": 28, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "NFTokenSellOffer", + "DisabledValidators", { - "nth": 29, + "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "TickSize", + "HookExecutions", { - "nth": 16, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STArray" } ], [ - "UNLModifyDisabling", + "HookParameters", { - "nth": 17, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STArray" } ], [ - "DestinationNode", + "HookGrants", { - "nth": 9, + "nth": 20, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ], [ - "Cookie", + "XChainClaimAttestations", { - "nth": 10, + "nth": 21, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ], [ - "ServerVersion", + "XChainCreateAccountAttestations", { - "nth": 11, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ], [ - "NFTokenOfferNode", + "AuthAccounts", { - "nth": 12, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ] ], @@ -1810,6 +2632,9 @@ "telCAN_NOT_QUEUE_BLOCKED": -389, "telCAN_NOT_QUEUE_FEE": -388, "telCAN_NOT_QUEUE_FULL": -387, + "telWRONG_NETWORK": -386, + "telREQUIRES_NETWORK_ID": -385, + "telNETWORK_ID_MAKES_TX_NON_CANONICAL": -384, "temMALFORMED": -299, "temBAD_AMOUNT": -298, @@ -1844,10 +2669,18 @@ "temBAD_TICK_SIZE": -269, "temINVALID_ACCOUNT_ID": -268, "temCANNOT_PREAUTH_SELF": -267, - "temUNCERTAIN": -266, - "temUNKNOWN": -265, - "temSEQ_AND_TICKET": -264, - "temBAD_NFTOKEN_TRANSFER_FEE": -263, + "temINVALID_COUNT": -266, + "temUNCERTAIN": -265, + "temUNKNOWN": -264, + "temSEQ_AND_TICKET": -263, + "temBAD_NFTOKEN_TRANSFER_FEE": -262, + "temBAD_AMM_TOKENS": -261, + "temXCHAIN_EQUAL_DOOR_ACCOUNTS": -260, + "temXCHAIN_BAD_PROOF": -259, + "temXCHAIN_BRIDGE_BAD_ISSUES": -258, + "temXCHAIN_BRIDGE_NONDOOR_OWNER": -257, + "temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -256, + "temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -255, "tefFAILURE": -199, "tefALREADY": -198, @@ -1883,6 +2716,8 @@ "terNO_RIPPLE": -90, "terQUEUED": -89, "terPRE_TICKET": -88, + "terNO_AMM": -87, + "terSUBMITTED": -86, "tesSUCCESS": 0, @@ -1924,7 +2759,7 @@ "tecKILLED": 150, "tecHAS_OBLIGATIONS": 151, "tecTOO_SOON": 152, - + "tecHOOK_ERROR": 153, "tecMAX_SEQUENCE_REACHED": 154, "tecNO_SUITABLE_NFTOKEN_PAGE": 155, "tecNFTOKEN_BUY_SELL_MISMATCH": 156, @@ -1933,12 +2768,34 @@ "tecINSUFFICIENT_FUNDS": 159, "tecOBJECT_NOT_FOUND": 160, "tecINSUFFICIENT_PAYMENT": 161, - "tecINCORRECT_ASSET": 162, - "tecTOO_MANY": 163 + "tecUNFUNDED_AMM": 162, + "tecAMM_BALANCE": 163, + "tecAMM_FAILED": 164, + "tecAMM_INVALID_TOKENS": 165, + "tecAMM_EMPTY": 166, + "tecAMM_NOT_EMPTY": 167, + "tecAMM_ACCOUNT": 168, + "tecINCOMPLETE": 169, + "tecXCHAIN_BAD_TRANSFER_ISSUE": 170, + "tecXCHAIN_NO_CLAIM_ID": 171, + "tecXCHAIN_BAD_CLAIM_ID": 172, + "tecXCHAIN_CLAIM_NO_QUORUM": 173, + "tecXCHAIN_PROOF_UNKNOWN_KEY": 174, + "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 175, + "tecXCHAIN_WRONG_CHAIN": 176, + "tecXCHAIN_REWARD_MISMATCH": 177, + "tecXCHAIN_NO_SIGNERS_LIST": 178, + "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 179, + "tecXCHAIN_INSUFF_CREATE_AMOUNT": 180, + "tecXCHAIN_ACCOUNT_CREATE_PAST": 181, + "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 182, + "tecXCHAIN_PAYMENT_FAILED": 183, + "tecXCHAIN_SELF_COMMIT": 184, + "tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 185, + "tecXCHAIN_CREATE_ACCOUNT_DISABLED": 186 }, "TRANSACTION_TYPES": { "Invalid": -1, - "Payment": 0, "EscrowCreate": 1, "EscrowFinish": 2, @@ -1961,13 +2818,29 @@ "DepositPreauth": 19, "TrustSet": 20, "AccountDelete": 21, + "SetHook": 22, "NFTokenMint": 25, "NFTokenBurn": 26, "NFTokenCreateOffer": 27, "NFTokenCancelOffer": 28, "NFTokenAcceptOffer": 29, + "Clawback": 30, + "AMMCreate": 35, + "AMMDeposit": 36, + "AMMWithdraw": 37, + "AMMVote": 38, + "AMMBid": 39, + "AMMDelete": 40, + "XChainCreateClaimID": 41, + "XChainCommit": 42, + "XChainClaim": 43, + "XChainAccountCreateCommit": 44, + "XChainAddClaimAttestation": 45, + "XChainAddAccountCreateAttestation": 46, + "XChainModifyBridge": 47, + "XChainCreateBridge": 48, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 } -} \ No newline at end of file +} From 5187c9fae462f59191e5d43ad98ccd85088595d6 Mon Sep 17 00:00:00 2001 From: JCrawsh Date: Tue, 14 Nov 2023 19:05:30 +0000 Subject: [PATCH 26/32] chore: added tests for uint types --- binary-codec/types/uint16.go | 31 +++++---------- binary-codec/types/uint16_test.go | 63 +++++++++++++++++++++++++++++++ binary-codec/types/uint32.go | 20 +++++++--- binary-codec/types/uint32_test.go | 56 +++++++++++++++++++++++++++ binary-codec/types/uint8.go | 22 +++++------ binary-codec/types/uint8_test.go | 56 +++++++++++++++++++++++++++ model/ledger/signer_list.go | 6 +-- 7 files changed, 212 insertions(+), 42 deletions(-) create mode 100644 binary-codec/types/uint16_test.go create mode 100644 binary-codec/types/uint32_test.go create mode 100644 binary-codec/types/uint8_test.go diff --git a/binary-codec/types/uint16.go b/binary-codec/types/uint16.go index 80ada5b0..352a44f8 100644 --- a/binary-codec/types/uint16.go +++ b/binary-codec/types/uint16.go @@ -18,44 +18,31 @@ type UInt16 struct{} // method will attempt to convert it into a corresponding type code. If the conversion fails, an error is returned. func (u *UInt16) FromJson(value any) ([]byte, error) { switch v := value.(type) { + case uint16: + value = v + case uint: + value = uint16(v) + case int: + value = uint16(v) case transactions.TxType: tc, err := definitions.Get().GetTransactionTypeCodeByTransactionTypeName(string(v)) if err != nil { return nil, err } - value = int(tc) + value = uint16(tc) case ledger.LedgerEntryType: tc, err := definitions.Get().GetLedgerEntryTypeCodeByLedgerEntryTypeName(string(v)) if err != nil { return nil, err } - value = int(tc) + value = uint16(tc) } buf := new(bytes.Buffer) - err := binary.Write(buf, binary.BigEndian, uint16(value.(int))) + err := binary.Write(buf, binary.BigEndian, value) if err != nil { return nil, err } return buf.Bytes(), nil - - // if _, ok := value.(string); ok { - // tc, err := definitions.Get().GetTransactionTypeCodeByTransactionTypeName(value.(string)) - // if err != nil { - // tc, err = definitions.Get().GetLedgerEntryTypeCodeByLedgerEntryTypeName(value.(string)) - // if err != nil { - // return nil, err - // } - // } - // value = int(tc) - // } - - // buf := new(bytes.Buffer) - // err := binary.Write(buf, binary.BigEndian, uint16(value.(int))) - - // if err != nil { - // return nil, err - // } - // return buf.Bytes(), nil } // ToJson takes a BinaryParser and optional parameters, and converts the serialized byte data diff --git a/binary-codec/types/uint16_test.go b/binary-codec/types/uint16_test.go new file mode 100644 index 00000000..7fadd40a --- /dev/null +++ b/binary-codec/types/uint16_test.go @@ -0,0 +1,63 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/xyield/xrpl-go/model/ledger" + "github.com/xyield/xrpl-go/model/transactions" +) + +func TestUInt16FromJson(t *testing.T) { + tt := []struct { + description string + input any + expected []byte + expectedErr error + }{ + { + description: "convert uint16", + input: uint16(1), + expected: []byte{0, 1}, + expectedErr: nil, + }, + { + description: "convert uint", + input: uint(1), + expected: []byte{0, 1}, + expectedErr: nil, + }, + { + description: "convert int", + input: int(1), + expected: []byte{0, 1}, + expectedErr: nil, + }, + { + description: "convert TxType", + input: transactions.PaymentTx, + expected: []byte{0, 0}, + expectedErr: nil, + }, + { + description: "convert LedgerEntryType", + input: ledger.AccountRootEntry, + expected: []byte{0, 97}, + expectedErr: nil, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + u16 := &UInt16{} + got, err := u16.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + } +} diff --git a/binary-codec/types/uint32.go b/binary-codec/types/uint32.go index 229be01c..e96c428f 100644 --- a/binary-codec/types/uint32.go +++ b/binary-codec/types/uint32.go @@ -3,20 +3,26 @@ package types import ( "bytes" "encoding/binary" + "errors" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" "github.com/CreatureDev/xrpl-go/model/transactions/types" ) +var ErrInvalidUInt32 = errors.New("invalid type for UInt32") + // UInt32 represents a 32-bit unsigned integer. type UInt32 struct{} // FromJson converts a JSON value into a serialized byte slice representing a 32-bit unsigned integer. // The input value is assumed to be an integer. If the serialization fails, an error is returned. func (u *UInt32) FromJson(value any) ([]byte, error) { - v := expandInt(value) + v, err := expandInt(value) + if err != nil { + return nil, err + } buf := new(bytes.Buffer) - err := binary.Write(buf, binary.BigEndian, v) + err = binary.Write(buf, binary.BigEndian, v) if err != nil { return nil, err @@ -35,13 +41,15 @@ func (u *UInt32) ToJson(p *serdes.BinaryParser, opts ...int) (any, error) { return int(binary.BigEndian.Uint32(b)), nil } -func expandInt(v any) uint32 { +func expandInt(v any) (uint32, error) { switch v := v.(type) { case types.FlagsI: - return v.ToUint() + return v.ToUint(), nil case uint: - return uint32(v) + return uint32(v), nil + case uint32: + return v, nil default: - return v.(uint32) + return 0, ErrInvalidUInt32 } } diff --git a/binary-codec/types/uint32_test.go b/binary-codec/types/uint32_test.go new file mode 100644 index 00000000..fd657229 --- /dev/null +++ b/binary-codec/types/uint32_test.go @@ -0,0 +1,56 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/xyield/xrpl-go/model/transactions/types" +) + +func TestUint32FromJson(t *testing.T) { + tt := []struct { + description string + input any + expected []byte + expectedErr error + }{ + { + description: "convert uint32", + input: uint32(1), + expected: []byte{0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "convert uint", + input: uint(1), + expected: []byte{0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "convert flag", + input: types.SetFlag(1), + expected: []byte{0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "invalid type should error", + input: "invalid", + expected: nil, + expectedErr: ErrInvalidUInt32, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + u32 := &UInt32{} + got, err := u32.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + } +} diff --git a/binary-codec/types/uint8.go b/binary-codec/types/uint8.go index aeaa071e..578a3988 100644 --- a/binary-codec/types/uint8.go +++ b/binary-codec/types/uint8.go @@ -15,25 +15,25 @@ type UInt8 struct{} // If the input value is a string, it's assumed to be a transaction result name, and the method will // attempt to convert it into a transaction result type code. If the conversion fails, an error is returned. func (u *UInt8) FromJson(value any) ([]byte, error) { - if s, ok := value.(string); ok { - tc, err := definitions.Get().GetTransactionResultTypeCodeByTransactionResultName(s) + var u8 uint8 + + switch v := value.(type) { + case string: + tc, err := definitions.Get().GetTransactionResultTypeCodeByTransactionResultName(v) if err != nil { return nil, err } - value = tc - } - - var intValue int - - switch v := value.(type) { + u8 = uint8(tc) + case uint8: + u8 = v case int: - intValue = v + u8 = uint8(v) case int32: - intValue = int(v) + u8 = uint8(v) } buf := new(bytes.Buffer) - err := binary.Write(buf, binary.BigEndian, uint8(intValue)) + err := binary.Write(buf, binary.BigEndian, u8) if err != nil { return nil, err } diff --git a/binary-codec/types/uint8_test.go b/binary-codec/types/uint8_test.go new file mode 100644 index 00000000..32533934 --- /dev/null +++ b/binary-codec/types/uint8_test.go @@ -0,0 +1,56 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/xyield/xrpl-go/binary-codec/definitions" +) + +func TestUint8FromJson(t *testing.T) { + tt := []struct { + description string + input any + expected []byte + expectedErr error + }{ + { + description: "find transaction code", + input: "tecAMM_ACCOUNT", + expected: []byte{168}, + expectedErr: nil, + }, + { + description: "regular uint8", + input: uint8(30), + expected: []byte{30}, + expectedErr: nil, + }, + { + description: "regular int", + input: int(30), + expected: []byte{30}, + expectedErr: nil, + }, + { + description: "invalid transaction result", + input: "invalid", + expected: nil, + expectedErr: &definitions.NotFoundError{Instance: "TransactionResultName", Input: "invalid"}, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + u8 := &UInt8{} + got, err := u8.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + } +} diff --git a/model/ledger/signer_list.go b/model/ledger/signer_list.go index e8c7e5ac..c59efe83 100644 --- a/model/ledger/signer_list.go +++ b/model/ledger/signer_list.go @@ -19,8 +19,8 @@ type SignerList struct { PreviousTxnLgrSeq uint32 OwnerNode string SignerEntries []SignerEntryWrapper - SignerListID uint64 - SignerQuorum uint64 + SignerListID uint32 + SignerQuorum uint32 } type SignerEntryWrapper struct { @@ -29,7 +29,7 @@ type SignerEntryWrapper struct { type SignerEntry struct { Account types.Address - SignerWeight uint64 + SignerWeight uint16 WalletLocator types.Hash256 `json:",omitempty"` } From 6a059d548baa04c5ed63cd643c7595c1467a6ab9 Mon Sep 17 00:00:00 2001 From: JCrawsh Date: Tue, 14 Nov 2023 19:38:24 +0000 Subject: [PATCH 27/32] chore: updated uint64 type and added tests --- binary-codec/types/uint64.go | 44 ++++++++++---------- binary-codec/types/uint64_test.go | 67 +++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 22 deletions(-) create mode 100644 binary-codec/types/uint64_test.go diff --git a/binary-codec/types/uint64.go b/binary-codec/types/uint64.go index 9de5a278..659c590a 100644 --- a/binary-codec/types/uint64.go +++ b/binary-codec/types/uint64.go @@ -6,16 +6,20 @@ import ( "encoding/hex" "errors" "regexp" - "strconv" "strings" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) +var UINT64_HEX_REGEX = regexp.MustCompile("^[0-9a-fA-F]{1,16}$") + // UInt64 represents a 64-bit unsigned integer. type UInt64 struct{} -var ErrInvalidUInt64String error = errors.New("invalid UInt64 string, value should be a string representation of a UInt64") +var ( + ErrInvalidUInt64String error = errors.New("invalid UInt64 string, value should be hex encoded") + ErrInvalidUInt64Value error = errors.New("invalid UInt64 value, value should be an uint or a hex encoded string") +) // FromJson converts a JSON value into a serialized byte slice representing a 64-bit unsigned integer. // The input value is assumed to be a string representation of an integer. If the serialization fails, an error is returned. @@ -23,34 +27,32 @@ func (u *UInt64) FromJson(value any) ([]byte, error) { var buf = new(bytes.Buffer) - if _, ok := value.(string); !ok { - return nil, ErrInvalidUInt64String - } - - if !isNumeric(value.(string)) { - if hex, err := hex.DecodeString(value.(string)); err == nil { - buf.Write(hex) - return buf.Bytes(), nil - } - stringToUint64, err := strconv.ParseUint(value.(string), 10, 64) + switch v := value.(type) { + case uint64: + value = v + err := binary.Write(buf, binary.BigEndian, value) if err != nil { return nil, err } - value = stringToUint64 - err = binary.Write(buf, binary.BigEndian, value) + case uint: + value = uint64(v) + err := binary.Write(buf, binary.BigEndian, value) if err != nil { return nil, err } - return buf.Bytes(), nil - } else { - value = strings.Repeat("0", 16-len(value.(string))) + value.(string) // right justify the string + case string: + if !UINT64_HEX_REGEX.MatchString(v) { + return nil, ErrInvalidUInt64String + } + value = rjust(v, 16, "0") // right justify the string decoded, err := hex.DecodeString(value.(string)) if err != nil { return nil, err } buf.Write(decoded) + default: + return nil, ErrInvalidUInt64Value } - return buf.Bytes(), nil } @@ -65,8 +67,6 @@ func (u *UInt64) ToJson(p *serdes.BinaryParser, opts ...int) (any, error) { return strings.ToUpper(hex.EncodeToString(b)), nil } -// isNumeric checks if a string only contains numerical values. -func isNumeric(s string) bool { - match, _ := regexp.MatchString("^[0-9]+$", s) - return match +func rjust(s string, n int, pad string) string { + return strings.Repeat(pad, n-len(s)) + s } diff --git a/binary-codec/types/uint64_test.go b/binary-codec/types/uint64_test.go new file mode 100644 index 00000000..4dde35f3 --- /dev/null +++ b/binary-codec/types/uint64_test.go @@ -0,0 +1,67 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestUint64FromJson(t *testing.T) { + tt := []struct { + description string + input any + expected []byte + expectedErr error + }{ + { + description: "convert uint64", + input: uint64(1), + expected: []byte{0, 0, 0, 0, 0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "convert uint", + input: uint(1), + expected: []byte{0, 0, 0, 0, 0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "convert hex encoded string", + input: "0000000000000001", + expected: []byte{0, 0, 0, 0, 0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "convert short hex encoded string", + input: "10", + expected: []byte{0, 0, 0, 0, 0, 0, 0, 16}, + expectedErr: nil, + }, + { + description: "invalid string should error", + input: "invalid", + expected: nil, + expectedErr: ErrInvalidUInt64String, + }, + { + description: "invalid type should error", + input: -54, + expected: nil, + expectedErr: ErrInvalidUInt64Value, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + u64 := &UInt64{} + got, err := u64.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + } +} From 4784faf3eb7431017133fb9600cedddb24bc60d6 Mon Sep 17 00:00:00 2001 From: JCrawsh Date: Thu, 4 Jan 2024 14:24:04 +0000 Subject: [PATCH 28/32] chore: passing tests for all encode methods --- binary-codec/main.go | 136 +++++---- binary-codec/main_test.go | 382 +++++++++++++------------- binary-codec/types/account_id.go | 17 +- binary-codec/types/account_id_test.go | 50 ++++ binary-codec/types/blob.go | 8 +- binary-codec/types/blob_test.go | 43 +++ binary-codec/types/hash.go | 5 + binary-codec/types/hash128.go | 2 + binary-codec/types/hash128_test.go | 50 ++++ binary-codec/types/hash160.go | 3 + binary-codec/types/hash160_test.go | 44 +++ binary-codec/types/hash256.go | 2 + binary-codec/types/hash256_test.go | 52 ++++ binary-codec/types/st_object.go | 32 ++- 14 files changed, 555 insertions(+), 271 deletions(-) create mode 100644 binary-codec/types/account_id_test.go create mode 100644 binary-codec/types/blob_test.go create mode 100644 binary-codec/types/hash128_test.go create mode 100644 binary-codec/types/hash160_test.go create mode 100644 binary-codec/types/hash256_test.go diff --git a/binary-codec/main.go b/binary-codec/main.go index 0244a9c6..373de931 100644 --- a/binary-codec/main.go +++ b/binary-codec/main.go @@ -4,12 +4,13 @@ import ( "bytes" "encoding/hex" "errors" + "reflect" "strings" - "github.com/CreatureDev/xrpl-go/binary-codec/definitions" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" "github.com/CreatureDev/xrpl-go/binary-codec/types" - "github.com/CreatureDev/xrpl-go/model/transactions" ) var ErrSigningClaimFieldNotFound = errors.New("'Channel' & 'Amount' fields are both required, but were not found") @@ -20,10 +21,11 @@ const ( txSigPrefix = "53545800" ) -// Encode converts a JSON transaction object to a hex string in the canonical binary format. -// The binary format is defined in XRPL's core codebase. -func Encode(tx transactions.Tx) (string, error) { - st := &types.STObject{} +func encode(tx transactions.Tx, onlySigning bool, mutations map[string]types.FieldMutation) (string, error) { + st := &types.STObject{ + OnlySigning: onlySigning, + Mutations: mutations, + } b, err := st.FromJson(tx) if err != nil { return "", err @@ -32,58 +34,69 @@ func Encode(tx transactions.Tx) (string, error) { return strings.ToUpper(hex.EncodeToString(b)), nil } +// Encode converts a JSON transaction object to a hex string in the canonical binary format. +// The binary format is defined in XRPL's core codebase. +func Encode(tx transactions.Tx, onlySigning bool) (string, error) { + return encode(tx, onlySigning, nil) +} + // EncodeForMultiSign: encodes a transaction into binary format in preparation for providing one // signature towards a multi-signed transaction. // (Only encodes fields that are intended to be signed.) -// func EncodeForMultisigning(json map[string]any, xrpAccountID string) (string, error) { - -// st := &types.AccountID{} - -// // SigningPubKey is required for multi-signing but should be set to empty string. +func EncodeForMultisigning(tx transactions.Tx, xrpAccountID string) (string, error) { -// json["SigningPubKey"] = "" + st := &types.AccountID{} -// suffix, err := st.FromJson(xrpAccountID) -// if err != nil { -// return "", err -// } + suffix, err := st.FromJson(xrpAccountID) + if err != nil { + return "", err + } -// encoded, err := Encode(removeNonSigningFields(json)) + // SigningPubKey is required for multi-signing but should be set to empty string. + err = setFieldFromTx(tx, "SigningPubKey", "placeholder", func(v any) bool { + return v.(string) == "" + }) + if err != nil { + return "", err + } + encoded, err := encode(tx, true, map[string]types.FieldMutation{ + "SigningPubKey": types.Zero(), + }) -// if err != nil { -// return "", err -// } + if err != nil { + return "", err + } -// return strings.ToUpper(txMultiSigPrefix + encoded + hex.EncodeToString(suffix)), nil -// } + return strings.ToUpper(txMultiSigPrefix + encoded + hex.EncodeToString(suffix)), nil +} // Encodes a transaction into binary format in preparation for signing. -// func EncodeForSigning(json map[string]any) (string, error) { +func EncodeForSigning(tx transactions.Tx) (string, error) { -// encoded, err := Encode(removeNonSigningFields(json)) + encoded, err := Encode(tx, true) -// if err != nil { -// return "", err -// } + if err != nil { + return "", err + } -// return strings.ToUpper(txSigPrefix + encoded), nil -// } + return strings.ToUpper(txSigPrefix + encoded), nil +} // EncodeForPaymentChannelClaim: encodes a payment channel claim into binary format in preparation for signing. -func EncodeForSigningClaim(json map[string]any) (string, error) { +func EncodeForSigningClaim(tx transactions.PaymentChannelClaim) (string, error) { - if json["Channel"] == nil || json["Amount"] == nil { + if tx.Channel == "" || tx.Amount == 0 { return "", ErrSigningClaimFieldNotFound } - channel, err := types.NewHash256().FromJson(json["Channel"]) + channel, err := types.NewHash256().FromJson(tx.Channel) if err != nil { return "", err } t := &types.Amount{} - amount, err := t.FromJson(json["Amount"]) + amount, err := t.FromJson(tx.Amount) if err != nil { return "", err @@ -97,20 +110,6 @@ func EncodeForSigningClaim(json map[string]any) (string, error) { return strings.ToUpper(paymentChannelClaimPrefix + hex.EncodeToString(channel) + hex.EncodeToString(amount)), nil } -// removeNonSigningFields removes the fields from a JSON transaction object that should not be signed. -func removeNonSigningFields(json map[string]any) map[string]any { - - for k := range json { - fi, _ := definitions.Get().GetFieldInstanceByFieldName(k) - - if fi != nil && !fi.IsSigningField { - delete(json, k) - } - } - - return json -} - // Decode decodes a hex string in the canonical binary format into a JSON transaction object. func Decode(hexEncoded string) (map[string]any, error) { b, err := hex.DecodeString(hexEncoded) @@ -127,29 +126,20 @@ func Decode(hexEncoded string) (map[string]any, error) { return m.(map[string]any), nil } -// func flattenTx(tx transactions.Tx) (map[string]any, error) { -// rv := reflect.ValueOf(tx) -// if rv.Kind() == reflect.Ptr { -// rv = rv.Elem() -// } else { -// return nil, errors.New("invalid transaction") -// } -// m := make(map[string]any) -// baseTx := rv.FieldByName("BaseTx") -// if !baseTx.IsValid() { -// return nil, errors.New("no base tx defined") -// } -// for i := 0; i < baseTx.NumField(); i++ { -// if baseTx.Field(i).IsZero() { -// continue -// } -// m[baseTx.Type().Field(i).Name] = baseTx.Field(i).Interface() -// } -// for i := 0; i < rv.NumField(); i++ { -// if rv.Field(i).IsZero() || rv.Type().Field(i).Name == "BaseTx" { -// continue -// } -// m[rv.Type().Field(i).Name] = rv.Field(i).Interface() -// } -// return m, nil -// } +// Overwrites a field in a transaction with a new value if condition is met. +func setFieldFromTx(tx transactions.Tx, fieldName string, value any, condition func(any) bool) error { + rv := reflect.ValueOf(tx) + if rv.Kind() == reflect.Ptr { + rv = rv.Elem() + } else { + return errors.New("invalid transaction") + } + if !rv.FieldByName(fieldName).IsValid() { + return errors.New("invalid field name") + } + if condition != nil && condition(rv.FieldByName(fieldName).Interface()) { + rv.FieldByName(fieldName).Set(reflect.ValueOf(value)) + return nil + } + return nil +} diff --git a/binary-codec/main_test.go b/binary-codec/main_test.go index 6048ed43..f338b0cf 100644 --- a/binary-codec/main_test.go +++ b/binary-codec/main_test.go @@ -121,7 +121,7 @@ func TestEncode(t *testing.T) { for _, tc := range tt { t.Run(tc.description, func(t *testing.T) { - got, err := Encode(tc.input) + got, err := Encode(tc.input, false) if tc.expectedErr != nil { require.EqualError(t, err, tc.expectedErr.Error()) @@ -241,205 +241,199 @@ func TestDecode(t *testing.T) { } -// func TestEncodeForMultisigning(t *testing.T) { -// tt := []struct { -// description string -// json map[string]any -// accountID string -// output string -// expectedErr error -// }{ -// { -// description: "serialize tx1 for signing correctly", -// json: map[string]any{ -// "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", -// "Expiration": 595640108, -// "Fee": "10", -// "Flags": 524288, -// "OfferSequence": 1752791, -// "Sequence": 1752792, -// "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", -// "TakerGets": "15000000000", -// "TakerPays": map[string]any{ -// "currency": "USD", -// "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", -// "value": "7072.8", -// }, -// "TransactionType": "OfferCreate", -// "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", -// "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", -// }, -// accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", -// output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", -// expectedErr: nil, -// }, -// { -// description: "SigningPubKey is not present", -// json: map[string]any{ -// "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", -// "Expiration": 595640108, -// "Fee": "10", -// "Flags": 524288, -// "OfferSequence": 1752791, -// "Sequence": 1752792, -// "TakerGets": "15000000000", -// "TakerPays": map[string]any{ -// "currency": "USD", -// "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", -// "value": "7072.8", -// }, -// "TransactionType": "OfferCreate", -// "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", -// "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", -// }, -// accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", -// output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", -// expectedErr: nil, -// }, -// { -// description: "SigningPubKey empty string", -// json: map[string]any{ -// "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", -// "Expiration": 595640108, -// "Fee": "10", -// "Flags": 524288, -// "OfferSequence": 1752791, -// "Sequence": 1752792, -// "SigningPubKey": "", -// "TakerGets": "15000000000", -// "TakerPays": map[string]any{ -// "currency": "USD", -// "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", -// "value": "7072.8", -// }, -// "TransactionType": "OfferCreate", -// "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", -// "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", -// }, -// accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", -// output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", -// expectedErr: nil, -// }, -// } +func TestEncodeForMultisigning(t *testing.T) { + tt := []struct { + description string + input transactions.Tx + accountID string + output string + expectedErr error + }{ + { + description: "serialize tx1 for signing correctly", + input: &transactions.OfferCreate{ + BaseTx: transactions.BaseTx{ + Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + TransactionType: transactions.OfferCreateTx, + Fee: 10, + Flags: types.SetFlag(524288), + Sequence: 1752792, + SigningPubKey: "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", + TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", + }, + Expiration: 595640108, + OfferSequence: 1752791, + TakerGets: types.XRPCurrencyAmount(15000000000), + TakerPays: types.IssuedCurrencyAmount{ + Currency: "USD", + Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + Value: "7072.8", + }, + }, + accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", + expectedErr: nil, + }, + { + description: "SigningPubKey is not present", + input: &transactions.OfferCreate{ + BaseTx: transactions.BaseTx{ + Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + TransactionType: transactions.OfferCreateTx, + Fee: 10, + Flags: types.SetFlag(524288), + Sequence: 1752792, + TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", + }, + Expiration: 595640108, + OfferSequence: 1752791, + TakerGets: types.XRPCurrencyAmount(15000000000), + TakerPays: types.IssuedCurrencyAmount{ + Currency: "USD", + Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + Value: "7072.8", + }, + }, + accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", + expectedErr: nil, + }, + { + description: "SigningPubKey empty string", + input: &transactions.OfferCreate{ + BaseTx: transactions.BaseTx{ + Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + TransactionType: transactions.OfferCreateTx, + Fee: 10, + Flags: types.SetFlag(524288), + Sequence: 1752792, + SigningPubKey: "", + TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", + }, + Expiration: 595640108, + OfferSequence: 1752791, + TakerGets: types.XRPCurrencyAmount(15000000000), + TakerPays: types.IssuedCurrencyAmount{ + Currency: "USD", + Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + Value: "7072.8", + }, + }, + accountID: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + output: "534D5400120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A73008114DD76483FACDEE26E60D8A586BB58D09F27045C46DD76483FACDEE26E60D8A586BB58D09F27045C46", + expectedErr: nil, + }, + } -// for _, tc := range tt { -// t.Run(tc.description, func(t *testing.T) { -// got, err := EncodeForMultisigning(tc.json, tc.accountID) + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + got, err := EncodeForMultisigning(tc.input, tc.accountID) -// if tc.expectedErr != nil { -// require.EqualError(t, err, tc.expectedErr.Error()) -// require.Empty(t, got) -// } else { -// require.NoError(t, err) -// require.Equal(t, tc.output, got) -// } -// }) -// } -// } + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.output, got) + } + }) + } +} -// func TestEncodeForSigningClaim(t *testing.T) { +func TestEncodeForSigningClaim(t *testing.T) { -// tt := []struct { -// description string -// input map[string]any -// output string -// expectedErr error -// }{ -// { -// description: "successfully encode claim", -// input: map[string]any{ -// "Channel": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1", -// "Amount": "1000", -// }, -// output: "434C4D0043904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB100000000000003E8", -// expectedErr: nil, -// }, -// { -// description: "fail to encode claim - no channel", -// input: map[string]any{ -// "Amount": "1000", -// }, -// output: "", -// expectedErr: ErrSigningClaimFieldNotFound, -// }, -// { -// description: "fail to encode claim - no amount", -// input: map[string]any{ -// "Channel": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1", -// }, -// output: "", -// expectedErr: ErrSigningClaimFieldNotFound, -// }, -// } + tt := []struct { + description string + input transactions.PaymentChannelClaim + output string + expectedErr error + }{ + { + description: "successfully encode claim", + input: transactions.PaymentChannelClaim{ + Channel: "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1", + Amount: 1000, + }, + output: "434C4D0043904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB100000000000003E8", + expectedErr: nil, + }, + { + description: "fail to encode claim - no channel", + input: transactions.PaymentChannelClaim{ + Amount: 1000, + }, + output: "", + expectedErr: ErrSigningClaimFieldNotFound, + }, + { + description: "fail to encode claim - no amount", + input: transactions.PaymentChannelClaim{ + Channel: "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1", + }, + output: "", + expectedErr: ErrSigningClaimFieldNotFound, + }, + } -// for _, tc := range tt { -// t.Run(tc.description, func(t *testing.T) { -// got, err := EncodeForSigningClaim(tc.input) + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + got, err := EncodeForSigningClaim(tc.input) -// if tc.expectedErr != nil { -// require.EqualError(t, err, tc.expectedErr.Error()) -// require.Empty(t, got) -// } else { -// require.NoError(t, err) -// require.Equal(t, tc.output, got) -// } -// }) -// } -// } + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.output, got) + } + }) + } +} -// func TestEncodeForSigning(t *testing.T) { -// tt := []struct { -// description string -// input map[string]any -// output string -// expectedErr error -// }{ -// { -// description: "serialize STObject for signing correctly", -// input: map[string]any{ -// "Memo": map[string]any{ -// "MemoType": "04C4D46544659A2D58525043686174", -// }, -// }, -// output: "53545800EA7C0F04C4D46544659A2D58525043686174E1", -// expectedErr: nil, -// }, -// { -// description: "serialize tx1 for signing correctly", -// input: map[string]any{ -// "Account": "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", -// "Expiration": 595640108, -// "Fee": "10", -// "Flags": 524288, -// "OfferSequence": 1752791, -// "Sequence": 1752792, -// "SigningPubKey": "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", -// "TakerGets": "15000000000", -// "TakerPays": map[string]any{ -// "currency": "USD", -// "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", -// "value": "7072.8", -// }, -// "TransactionType": "OfferCreate", -// "TxnSignature": "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", -// "hash": "73734B611DDA23D3F5F62E20A173B78AB8406AC5015094DA53F53D39B9EDB06C", -// }, -// output: "53545800120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE38114DD76483FACDEE26E60D8A586BB58D09F27045C46", -// expectedErr: nil, -// }, -// } +func TestEncodeForSigning(t *testing.T) { + tt := []struct { + description string + input transactions.Tx + output string + expectedErr error + }{ + { + description: "serialize tx1 for signing correctly", + input: &transactions.OfferCreate{ + BaseTx: transactions.BaseTx{ + Account: "rMBzp8CgpE441cp5PVyA9rpVV7oT8hP3ys", + TransactionType: transactions.OfferCreateTx, + Fee: 10, + Flags: types.SetFlag(524288), + Sequence: 1752792, + SigningPubKey: "03EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE3", + TxnSignature: "30440220143759437C04F7B61F012563AFE90D8DAFC46E86035E1D965A9CED282C97D4CE02204CFD241E86F17E011298FC1A39B63386C74306A5DE047E213B0F29EFA4571C2C", + }, + Expiration: 595640108, + OfferSequence: 1752791, + TakerGets: types.XRPCurrencyAmount(15000000000), + TakerPays: types.IssuedCurrencyAmount{ + Currency: "USD", + Issuer: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + Value: "7072.8", + }, + }, + output: "53545800120007220008000024001ABED82A2380BF2C2019001ABED764D55920AC9391400000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D165400000037E11D60068400000000000000A732103EE83BB432547885C219634A1BC407A9DB0474145D69737D09CCDC63E1DEE7FE38114DD76483FACDEE26E60D8A586BB58D09F27045C46", + expectedErr: nil, + }, + } -// for _, tc := range tt { -// t.Run(tc.description, func(t *testing.T) { -// got, err := EncodeForSigning(tc.input) + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + got, err := EncodeForSigning(tc.input) -// if tc.expectedErr != nil { -// require.EqualError(t, err, tc.expectedErr.Error()) -// require.Empty(t, got) -// } else { -// require.NoError(t, err) -// require.Equal(t, tc.output, got) -// } -// }) -// } -// } + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.output, got) + } + }) + } +} diff --git a/binary-codec/types/account_id.go b/binary-codec/types/account_id.go index bac19f47..2265acaf 100644 --- a/binary-codec/types/account_id.go +++ b/binary-codec/types/account_id.go @@ -1,11 +1,17 @@ package types import ( + "errors" + addresscodec "github.com/CreatureDev/xrpl-go/address-codec" "github.com/CreatureDev/xrpl-go/binary-codec/serdes" "github.com/CreatureDev/xrpl-go/model/transactions/types" ) +var ( + ErrInvalidAccountID = errors.New("invalid account ID type") +) + // AccountID struct represents an account ID. type AccountID struct{} @@ -18,7 +24,16 @@ type AccountID struct{} // AccountIDs that appear as children of special fields (Amount issuer and PathSet account) are not length-prefixed. // So in Amount and PathSet fields, don't use the length indicator 0x14. func (a *AccountID) FromJson(value any) ([]byte, error) { - _, accountID, err := addresscodec.DecodeClassicAddressToAccountID(string(value.(types.Address))) + var accountID []byte + var err error + switch v := value.(type) { + case types.Address: + _, accountID, err = addresscodec.DecodeClassicAddressToAccountID(string(v)) + case string: + _, accountID, err = addresscodec.DecodeClassicAddressToAccountID(v) + default: + return nil, ErrInvalidAccountID + } if err != nil { return nil, err diff --git a/binary-codec/types/account_id_test.go b/binary-codec/types/account_id_test.go new file mode 100644 index 00000000..41ca6f1d --- /dev/null +++ b/binary-codec/types/account_id_test.go @@ -0,0 +1,50 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/xyield/xrpl-go/model/transactions/types" +) + +func TestAccountIDFromJson(t *testing.T) { + tt := []struct { + description string + input any + expected []byte + expectedErr error + }{ + { + description: "convert address", + input: types.Address("r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"), + expected: []byte{0x5e, 0x7b, 0x11, 0x25, 0x23, 0xf6, 0x8d, 0x2f, 0x5e, 0x87, 0x9d, 0xb4, 0xea, 0xc5, 0x1c, 0x66, 0x98, 0xa6, 0x93, 0x4}, + expectedErr: nil, + }, + { + description: "convert address from string type", + input: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + expected: []byte{0x5e, 0x7b, 0x11, 0x25, 0x23, 0xf6, 0x8d, 0x2f, 0x5e, 0x87, 0x9d, 0xb4, 0xea, 0xc5, 0x1c, 0x66, 0x98, 0xa6, 0x93, 0x4}, + expectedErr: nil, + }, + { + description: "invalid type should error", + input: false, + expected: nil, + expectedErr: ErrInvalidAccountID, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + a := &AccountID{} + got, err := a.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + } +} diff --git a/binary-codec/types/blob.go b/binary-codec/types/blob.go index 8bf38f43..089c1b30 100644 --- a/binary-codec/types/blob.go +++ b/binary-codec/types/blob.go @@ -9,13 +9,19 @@ import ( ) // ErrNoLengthPrefix error is raised when no length prefix size is given. -var ErrNoLengthPrefix error = errors.New("no length prefix size given") +var ( + ErrNoLengthPrefix error = errors.New("no length prefix size given") + ErrInvalidBlobType error = errors.New("invalid type for Blob") +) // Blob struct is used for manipulating hexadecimal data. type Blob struct{} // FromJson method for Blob converts a hexadecimal string from JSON to a byte array. func (b *Blob) FromJson(json any) ([]byte, error) { + if _, ok := json.(string); !ok { + return nil, ErrInvalidBlobType + } // Convert hexadecimal string to byte array. // Return an error if the conversion fails. v, err := hex.DecodeString(json.(string)) diff --git a/binary-codec/types/blob_test.go b/binary-codec/types/blob_test.go new file mode 100644 index 00000000..ce6fd08b --- /dev/null +++ b/binary-codec/types/blob_test.go @@ -0,0 +1,43 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestBlobFromJson(t *testing.T) { + tt := []struct { + description string + input any + expected []byte + expectedErr error + }{ + { + description: "convert string", + input: "0000000000000001", + expected: []byte{0, 0, 0, 0, 0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "invalid type should error", + input: -54, + expected: nil, + expectedErr: ErrInvalidBlobType, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + b := &Blob{} + got, err := b.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + } +} diff --git a/binary-codec/types/hash.go b/binary-codec/types/hash.go index c41bd99b..f2f11680 100644 --- a/binary-codec/types/hash.go +++ b/binary-codec/types/hash.go @@ -1,9 +1,14 @@ package types import ( + "errors" "fmt" ) +var ( + ErrInvalidHashType = errors.New("invalid type for Hash, expected string") +) + // ErrInvalidHashLength struct is used when the hash length does not meet the expected value. type ErrInvalidHashLength struct { Expected int diff --git a/binary-codec/types/hash128.go b/binary-codec/types/hash128.go index 621ad257..c8ed725b 100644 --- a/binary-codec/types/hash128.go +++ b/binary-codec/types/hash128.go @@ -33,6 +33,8 @@ func (h *Hash128) FromJson(json any) ([]byte, error) { s = json case types.Hash128: s = string(json) + default: + return nil, ErrInvalidHashType } v, err := hex.DecodeString(s) if err != nil { diff --git a/binary-codec/types/hash128_test.go b/binary-codec/types/hash128_test.go new file mode 100644 index 00000000..9e669cb3 --- /dev/null +++ b/binary-codec/types/hash128_test.go @@ -0,0 +1,50 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/xyield/xrpl-go/model/transactions/types" +) + +func TestHash128FromJson(t *testing.T) { + tt := []struct { + description string + input any + expected []byte + expectedErr error + }{ + { + description: "convert string", + input: "00000000000000000000000000000001", + expected: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "convert hash128 type", + input: types.Hash128("00000000000000000000000000000001"), + expected: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "invalid type should error", + input: -54, + expected: nil, + expectedErr: ErrInvalidHashType, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + h128 := &Hash128{} + got, err := h128.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + } +} diff --git a/binary-codec/types/hash160.go b/binary-codec/types/hash160.go index c4999d90..4abefc09 100644 --- a/binary-codec/types/hash160.go +++ b/binary-codec/types/hash160.go @@ -26,6 +26,9 @@ func (h *Hash160) getLength() int { // FromJson method for hash converts a hexadecimal string from JSON to a byte array. // It returns an error if the conversion fails or the length of the decoded byte array is not as expected. func (h *Hash160) FromJson(json any) ([]byte, error) { + if _, ok := json.(string); !ok { + return nil, ErrInvalidHashType + } v, err := hex.DecodeString(json.(string)) if err != nil { return nil, err diff --git a/binary-codec/types/hash160_test.go b/binary-codec/types/hash160_test.go new file mode 100644 index 00000000..4a824a63 --- /dev/null +++ b/binary-codec/types/hash160_test.go @@ -0,0 +1,44 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestHash160FromJson(t *testing.T) { + tt := []struct { + description string + input any + expected []byte + expectedErr error + }{ + { + description: "convert string", + input: "0000000000000000000000000000000000000001", + expected: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, + expectedErr: nil, + }, + { + description: "invalid type", + input: -54, + expected: nil, + expectedErr: ErrInvalidHashType, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + h160 := &Hash160{} + got, err := h160.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + + } +} diff --git a/binary-codec/types/hash256.go b/binary-codec/types/hash256.go index 6e152fe4..6a7d781a 100644 --- a/binary-codec/types/hash256.go +++ b/binary-codec/types/hash256.go @@ -31,6 +31,8 @@ func (h *Hash256) FromJson(json any) ([]byte, error) { s = json case types.Hash256: s = string(json) + default: + return nil, ErrInvalidHashType } v, err := hex.DecodeString(s) if err != nil { diff --git a/binary-codec/types/hash256_test.go b/binary-codec/types/hash256_test.go new file mode 100644 index 00000000..924ebe69 --- /dev/null +++ b/binary-codec/types/hash256_test.go @@ -0,0 +1,52 @@ +package types + +import ( + "bytes" + "strings" + "testing" + + "github.com/stretchr/testify/require" + "github.com/xyield/xrpl-go/model/transactions/types" +) + +func TestHash256FromJson(t *testing.T) { + tt := []struct { + description string + input any + expected []byte + expectedErr error + }{ + { + description: "convert string", + input: strings.Repeat("0", 63) + "1", + expected: append(bytes.Repeat([]byte{0}, 31), byte(1)), + expectedErr: nil, + }, + { + description: "convert hash256 type", + input: types.Hash256(strings.Repeat("0", 63) + "1"), + expected: append(bytes.Repeat([]byte{0}, 31), byte(1)), + expectedErr: nil, + }, + { + description: "invalid type", + input: -54, + expected: nil, + expectedErr: ErrInvalidHashType, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + h256 := &Hash256{} + got, err := h256.FromJson(tc.input) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + require.Empty(t, got) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + } +} diff --git a/binary-codec/types/st_object.go b/binary-codec/types/st_object.go index 5fa47436..8c7f6b64 100644 --- a/binary-codec/types/st_object.go +++ b/binary-codec/types/st_object.go @@ -9,10 +9,23 @@ import ( "github.com/mitchellh/mapstructure" ) +// FieldMutation allows values to mutated before being serialized. +type FieldMutation func(any) any + +// Zero returns a FieldMutation that sets the value to its zero value. +func Zero() FieldMutation { + return func(v any) any { + return reflect.Zero(reflect.TypeOf(v)).Interface() + } +} + // STObject represents a map of serialized field instances, where each key is a field name // and the associated value is the field's value. This structure allows us to represent nested // and complex structures of the Ripple protocol. -type STObject struct{} +type STObject struct { + OnlySigning bool + Mutations map[string]FieldMutation +} // FromJson converts a JSON object into a serialized byte slice. // It works by converting the JSON object into a map of field instances (which include the field definition @@ -30,6 +43,12 @@ func (t *STObject) FromJson(json any) ([]byte, error) { return nil, err } + for k, v := range t.Mutations { + if _, ok := m[k]; ok { + m[k] = v(m[k]) + } + } + fimap, err := createFieldInstanceMapFromJson(m) if err != nil { @@ -39,7 +58,7 @@ func (t *STObject) FromJson(json any) ([]byte, error) { sk := getSortedKeys(fimap) for _, v := range sk { - if checkZero(fimap[v]) { + if checkZero(fimap[v]) && !containsKey(t.Mutations, v.FieldName) { continue } @@ -47,6 +66,10 @@ func (t *STObject) FromJson(json any) ([]byte, error) { continue } + if t.OnlySigning && !v.IsSigningField { + continue + } + st := GetSerializedType(v.Type) b, err := st.FromJson(fimap[v]) if err != nil { @@ -228,3 +251,8 @@ func checkZero(v any) bool { rv := reflect.ValueOf(v) return rv.IsZero() } + +func containsKey[T any](m map[string]T, key string) bool { + _, ok := m[key] + return ok +} From 88ec97d5a5d7408c35687c3d85321d159f40506d Mon Sep 17 00:00:00 2001 From: JCrawsh Date: Thu, 4 Jan 2024 14:58:03 +0000 Subject: [PATCH 29/32] chore: updated Encode method so don't need to include onlySigning input --- binary-codec/main.go | 6 +++--- binary-codec/main_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/binary-codec/main.go b/binary-codec/main.go index 373de931..515e22df 100644 --- a/binary-codec/main.go +++ b/binary-codec/main.go @@ -36,8 +36,8 @@ func encode(tx transactions.Tx, onlySigning bool, mutations map[string]types.Fie // Encode converts a JSON transaction object to a hex string in the canonical binary format. // The binary format is defined in XRPL's core codebase. -func Encode(tx transactions.Tx, onlySigning bool) (string, error) { - return encode(tx, onlySigning, nil) +func Encode(tx transactions.Tx) (string, error) { + return encode(tx, false, nil) } // EncodeForMultiSign: encodes a transaction into binary format in preparation for providing one @@ -73,7 +73,7 @@ func EncodeForMultisigning(tx transactions.Tx, xrpAccountID string) (string, err // Encodes a transaction into binary format in preparation for signing. func EncodeForSigning(tx transactions.Tx) (string, error) { - encoded, err := Encode(tx, true) + encoded, err := encode(tx, true, nil) if err != nil { return "", err diff --git a/binary-codec/main_test.go b/binary-codec/main_test.go index f338b0cf..f30da168 100644 --- a/binary-codec/main_test.go +++ b/binary-codec/main_test.go @@ -121,7 +121,7 @@ func TestEncode(t *testing.T) { for _, tc := range tt { t.Run(tc.description, func(t *testing.T) { - got, err := Encode(tc.input, false) + got, err := Encode(tc.input) if tc.expectedErr != nil { require.EqualError(t, err, tc.expectedErr.Error()) From 7f6fe94cb28542d883fa3ef63740d0e758f60824 Mon Sep 17 00:00:00 2001 From: PR Date: Mon, 19 Feb 2024 11:09:59 -0800 Subject: [PATCH 30/32] fix imports --- binary-codec/types/account_id_test.go | 2 +- binary-codec/types/hash128.go | 4 ++-- binary-codec/types/hash128_test.go | 2 +- binary-codec/types/hash160.go | 2 +- binary-codec/types/hash256.go | 4 ++-- binary-codec/types/hash256_test.go | 2 +- binary-codec/types/st_array_test.go | 6 +++--- binary-codec/types/uint16_test.go | 4 ++-- binary-codec/types/uint32_test.go | 2 +- binary-codec/types/uint8_test.go | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/binary-codec/types/account_id_test.go b/binary-codec/types/account_id_test.go index 41ca6f1d..b3a9a642 100644 --- a/binary-codec/types/account_id_test.go +++ b/binary-codec/types/account_id_test.go @@ -3,8 +3,8 @@ package types import ( "testing" + "github.com/CreatureDev/xrpl-go/model/transactions/types" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/model/transactions/types" ) func TestAccountIDFromJson(t *testing.T) { diff --git a/binary-codec/types/hash128.go b/binary-codec/types/hash128.go index c8ed725b..3eb62b84 100644 --- a/binary-codec/types/hash128.go +++ b/binary-codec/types/hash128.go @@ -4,8 +4,8 @@ import ( "encoding/hex" "strings" - "github.com/xyield/xrpl-go/binary-codec/serdes" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) var _ hashI = (*Hash128)(nil) diff --git a/binary-codec/types/hash128_test.go b/binary-codec/types/hash128_test.go index 9e669cb3..10b5f3af 100644 --- a/binary-codec/types/hash128_test.go +++ b/binary-codec/types/hash128_test.go @@ -3,8 +3,8 @@ package types import ( "testing" + "github.com/CreatureDev/xrpl-go/model/transactions/types" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/model/transactions/types" ) func TestHash128FromJson(t *testing.T) { diff --git a/binary-codec/types/hash160.go b/binary-codec/types/hash160.go index 4abefc09..0d92e985 100644 --- a/binary-codec/types/hash160.go +++ b/binary-codec/types/hash160.go @@ -4,7 +4,7 @@ import ( "encoding/hex" "strings" - "github.com/xyield/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" ) var _ hashI = (*Hash128)(nil) diff --git a/binary-codec/types/hash256.go b/binary-codec/types/hash256.go index 6a7d781a..10352e2c 100644 --- a/binary-codec/types/hash256.go +++ b/binary-codec/types/hash256.go @@ -4,8 +4,8 @@ import ( "encoding/hex" "strings" - "github.com/xyield/xrpl-go/binary-codec/serdes" - "github.com/xyield/xrpl-go/model/transactions/types" + "github.com/CreatureDev/xrpl-go/binary-codec/serdes" + "github.com/CreatureDev/xrpl-go/model/transactions/types" ) var _ hashI = (*Hash256)(nil) diff --git a/binary-codec/types/hash256_test.go b/binary-codec/types/hash256_test.go index 924ebe69..beb097f4 100644 --- a/binary-codec/types/hash256_test.go +++ b/binary-codec/types/hash256_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" + "github.com/CreatureDev/xrpl-go/model/transactions/types" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/model/transactions/types" ) func TestHash256FromJson(t *testing.T) { diff --git a/binary-codec/types/st_array_test.go b/binary-codec/types/st_array_test.go index fd705271..5e6d6165 100644 --- a/binary-codec/types/st_array_test.go +++ b/binary-codec/types/st_array_test.go @@ -5,10 +5,10 @@ import ( "strings" "testing" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions" + "github.com/CreatureDev/xrpl-go/model/transactions/types" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions" - "github.com/xyield/xrpl-go/model/transactions/types" ) func TestSTArrayFromJson(t *testing.T) { diff --git a/binary-codec/types/uint16_test.go b/binary-codec/types/uint16_test.go index 7fadd40a..6a2bed68 100644 --- a/binary-codec/types/uint16_test.go +++ b/binary-codec/types/uint16_test.go @@ -3,9 +3,9 @@ package types import ( "testing" + "github.com/CreatureDev/xrpl-go/model/ledger" + "github.com/CreatureDev/xrpl-go/model/transactions" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/model/ledger" - "github.com/xyield/xrpl-go/model/transactions" ) func TestUInt16FromJson(t *testing.T) { diff --git a/binary-codec/types/uint32_test.go b/binary-codec/types/uint32_test.go index fd657229..d109b936 100644 --- a/binary-codec/types/uint32_test.go +++ b/binary-codec/types/uint32_test.go @@ -3,8 +3,8 @@ package types import ( "testing" + "github.com/CreatureDev/xrpl-go/model/transactions/types" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/model/transactions/types" ) func TestUint32FromJson(t *testing.T) { diff --git a/binary-codec/types/uint8_test.go b/binary-codec/types/uint8_test.go index 32533934..72e8a16a 100644 --- a/binary-codec/types/uint8_test.go +++ b/binary-codec/types/uint8_test.go @@ -3,8 +3,8 @@ package types import ( "testing" + "github.com/CreatureDev/xrpl-go/binary-codec/definitions" "github.com/stretchr/testify/require" - "github.com/xyield/xrpl-go/binary-codec/definitions" ) func TestUint8FromJson(t *testing.T) { From 57b97484523d36aef4493175928df86ddaed2f6e Mon Sep 17 00:00:00 2001 From: PR Date: Mon, 19 Feb 2024 14:54:04 -0800 Subject: [PATCH 31/32] send response with error --- client/transactions.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/transactions.go b/client/transactions.go index 964e535a..3e63ef98 100644 --- a/client/transactions.go +++ b/client/transactions.go @@ -31,12 +31,12 @@ func (t *transactionImpl) SubmitMultisigned(req *transactions.SubmitMultisignedR func (t *transactionImpl) Submit(req *transactions.SubmitRequest) (*transactions.SubmitResponse, XRPLResponse, error) { res, err := t.client.SendRequest(req) if err != nil { - return nil, nil, err + return nil, res, err } var sr transactions.SubmitResponse err = res.GetResult(&sr) if err != nil { - return nil, nil, err + return nil, res, err } return &sr, res, nil } From b6876c2df821e05e304fd3d027cf36e7bb95db08 Mon Sep 17 00:00:00 2001 From: PR Date: Mon, 19 Feb 2024 14:57:43 -0800 Subject: [PATCH 32/32] have response with error --- client/jsonrpc/jsonrpc_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/jsonrpc/jsonrpc_client.go b/client/jsonrpc/jsonrpc_client.go index 74e6ba52..15a4eab4 100644 --- a/client/jsonrpc/jsonrpc_client.go +++ b/client/jsonrpc/jsonrpc_client.go @@ -112,7 +112,7 @@ func (c *JsonRpcClient) SendRequest(reqParams client.XRPLRequest) (client.XRPLRe var jr jsonrpcmodels.JsonRpcResponse jr, err = CheckForError(response) if err != nil { - return nil, err + return &jr, err } return &jr, nil