diff --git a/client/accounts.go b/client/accounts.go index 1bde9a1..da2e686 100644 --- a/client/accounts.go +++ b/client/accounts.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" "github.com/maestro-org/go-sdk/utils" @@ -21,6 +22,9 @@ func (c *Client) AccountAddresses( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var accountAddresses models.AccountAddresses err = json.NewDecoder(resp.Body).Decode(&accountAddresses) @@ -43,6 +47,9 @@ func (c *Client) AccountAssets( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var accountAssets models.AccountAssets err = json.NewDecoder(resp.Body).Decode(&accountAssets) @@ -65,6 +72,9 @@ func (c *Client) StakeAccountHistory( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var stakeAccountHistory models.StakeAccountHistory err = json.NewDecoder(resp.Body).Decode(&stakeAccountHistory) @@ -82,6 +92,10 @@ func (c *Client) StakeAccountInformation( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } + defer resp.Body.Close() var stakeAccountInformation models.StakeAccountInformation err = json.NewDecoder(resp.Body).Decode(&stakeAccountInformation) @@ -104,6 +118,9 @@ func (c *Client) StakeAccountRewards( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var stakeAccountRewards models.StakeAccountRewards err = json.NewDecoder(resp.Body).Decode(&stakeAccountRewards) @@ -126,6 +143,9 @@ func (c *Client) StakeAccountUpdates( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var stakeAccountUpdates models.StakeAccountUpdates err = json.NewDecoder(resp.Body).Decode(&stakeAccountUpdates) diff --git a/client/addresses.go b/client/addresses.go index b7e31d7..2086e98 100644 --- a/client/addresses.go +++ b/client/addresses.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" "github.com/maestro-org/go-sdk/utils" @@ -14,6 +15,9 @@ func (c *Client) DecodeAddress(address string) (*models.DecodedAddress, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var decodedAddress models.DecodedAddress err = json.NewDecoder(resp.Body).Decode(&decodedAddress) @@ -29,6 +33,9 @@ func (c *Client) AddressTransactionCount(address string) (*models.AddressTransac if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var addressTransactionCount models.AddressTransactionCount err = json.NewDecoder(resp.Body).Decode(&addressTransactionCount) @@ -51,6 +58,9 @@ func (c *Client) AddressTransactions( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var addressTransactions models.AddressTransactions err = json.NewDecoder(resp.Body).Decode(&addressTransactions) @@ -73,6 +83,9 @@ func (c *Client) PaymentCredentialTransactions( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var addressTransactions models.AddressTransactions err = json.NewDecoder(resp.Body).Decode(&addressTransactions) @@ -95,6 +108,9 @@ func (c *Client) UtxoReferencesAtAddress( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var utxoReferencesAtAddress models.UtxoReferencesAtAddress err = json.NewDecoder(resp.Body).Decode(&utxoReferencesAtAddress) @@ -117,6 +133,9 @@ func (c *Client) UtxosAtAddress( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var utxosAtAddress models.UtxosAtAddress err = json.NewDecoder(resp.Body).Decode(&utxosAtAddress) @@ -140,6 +159,9 @@ func (c *Client) UtxosAtAddresses( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var utxosAtAddress models.UtxosAtAddress err = json.NewDecoder(resp.Body).Decode(&utxosAtAddress) @@ -162,6 +184,9 @@ func (c *Client) UtxosByPaymentCredential( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var utxosAtAddress models.UtxosAtAddress err = json.NewDecoder(resp.Body).Decode(&utxosAtAddress) diff --git a/client/asset.go b/client/asset.go index e09184e..42ebe51 100644 --- a/client/asset.go +++ b/client/asset.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" "github.com/maestro-org/go-sdk/utils" @@ -21,6 +22,9 @@ func (c *Client) AccountsHoldingAsset( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var accountsHoldingAsset models.AccountsHoldingAsset err = json.NewDecoder(resp.Body).Decode(&accountsHoldingAsset) @@ -43,6 +47,9 @@ func (c *Client) AddressHoldingAsset( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var addressesHoldingAsset models.AddressesHoldingAsset err = json.NewDecoder(resp.Body).Decode(&addressesHoldingAsset) @@ -58,6 +65,9 @@ func (c *Client) Asset(assetId string) (*models.AssetInformations, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var assetInformation models.AssetInformations err = json.NewDecoder(resp.Body).Decode(&assetInformation) @@ -80,6 +90,9 @@ func (c *Client) AssetTransactions( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var assetTransactions models.AssetTransactions err = json.NewDecoder(resp.Body).Decode(&assetTransactions) @@ -102,6 +115,9 @@ func (c *Client) AssetUpdates( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var assetUpdates models.AssetUpdates err = json.NewDecoder(resp.Body).Decode(&assetUpdates) @@ -122,6 +138,9 @@ func (c *Client) AssetUtxos(assetId string, params *utils.Parameters) (*models.A if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var assetUtxos models.AssetUtxos err = json.NewDecoder(resp.Body).Decode(&assetUtxos) diff --git a/client/asset_policy.go b/client/asset_policy.go index 2c34e0e..2fc7cbf 100644 --- a/client/asset_policy.go +++ b/client/asset_policy.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" "github.com/maestro-org/go-sdk/utils" @@ -21,6 +22,9 @@ func (c *Client) AccountsHoldingPolicy( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var response models.AccountsHoldingPolicy err = json.NewDecoder(resp.Body).Decode(&response) @@ -43,6 +47,9 @@ func (c *Client) AddressesHoldingPolicy( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var response models.AddressesHoldingPolicy err = json.NewDecoder(resp.Body).Decode(&response) @@ -65,6 +72,9 @@ func (c *Client) SpecificPolicyInformations( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var response models.PolicyInformation err = json.NewDecoder(resp.Body).Decode(&response) @@ -87,6 +97,9 @@ func (c *Client) TransactionsMovingPolicy( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var response models.PolicyTransactions err = json.NewDecoder(resp.Body).Decode(&response) @@ -109,6 +122,9 @@ func (c *Client) UtxosContainingPolicy( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var response models.UtxosContainingPolicy err = json.NewDecoder(resp.Body).Decode(&response) diff --git a/client/datum.go b/client/datum.go index 17be2ce..6333ad6 100644 --- a/client/datum.go +++ b/client/datum.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" ) @@ -13,6 +14,9 @@ func (c *Client) DatumFromHash(hash string) (*models.DatumFromHash, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var datum models.DatumFromHash err = json.NewDecoder(resp.Body).Decode(&datum) diff --git a/client/ecosystem.go b/client/ecosystem.go index aa4c386..b22f190 100644 --- a/client/ecosystem.go +++ b/client/ecosystem.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" ) @@ -13,6 +14,9 @@ func (c *Client) ResolveAdaHandle(handle string) (*models.BasicResponse, error) if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var adaHandle models.BasicResponse err = json.NewDecoder(resp.Body).Decode(&adaHandle) diff --git a/client/epochs.go b/client/epochs.go index 22276c4..ec27e12 100644 --- a/client/epochs.go +++ b/client/epochs.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" ) @@ -13,6 +14,9 @@ func (c *Client) CurrentEpoch() (*models.EpochResp, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var currentEpoch models.EpochResp err = json.NewDecoder(resp.Body).Decode(¤tEpoch) @@ -28,6 +32,9 @@ func (c *Client) SpecificEpoch(epochNo int) (*models.EpochResp, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var specificEpoch models.EpochResp err = json.NewDecoder(resp.Body).Decode(&specificEpoch) diff --git a/client/general.go b/client/general.go index c74ef22..d89a924 100644 --- a/client/general.go +++ b/client/general.go @@ -2,6 +2,8 @@ package client import ( "encoding/json" + "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" ) @@ -12,6 +14,9 @@ func (c *Client) ChainTip() (*models.ChainTip, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var chainTip models.ChainTip err = json.NewDecoder(resp.Body).Decode(&chainTip) @@ -27,6 +32,9 @@ func (c *Client) EraHistory() (*models.EraHistory, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var eraHistory models.EraHistory err = json.NewDecoder(resp.Body).Decode(&eraHistory) @@ -42,6 +50,9 @@ func (c *Client) ProtocolParameters() (*models.ProtocolParameters, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var protocolParameters models.ProtocolParameters err = json.NewDecoder(resp.Body).Decode(&protocolParameters) @@ -57,6 +68,9 @@ func (c *Client) BlockChainStartTime() (models.BasicResponse, error) { if err != nil { return models.BasicResponse{}, err } + if resp.StatusCode != http.StatusOK { + return models.BasicResponse{}, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var blockchainStartTime models.BasicResponse err = json.NewDecoder(resp.Body).Decode(&blockchainStartTime) diff --git a/client/linear_vesting.go b/client/linear_vesting.go index 1e52d3b..2f668df 100644 --- a/client/linear_vesting.go +++ b/client/linear_vesting.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" ) @@ -27,6 +28,9 @@ func (c *Client) LockAssets(lockBody LockBody) (*models.LockTransaction, error) if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var lockTransaction models.LockTransaction err = json.NewDecoder(resp.Body).Decode(&lockTransaction) @@ -42,6 +46,9 @@ func (c *Client) StateOfVestingAssets(beneficiary string) (*[]models.VestingStat if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var vestingStates []models.VestingState err = json.NewDecoder(resp.Body).Decode(&vestingStates) @@ -58,6 +65,9 @@ func (c *Client) CollectAssets(beneficiary string) (*models.CollectTransaction, if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var collectTransaction models.CollectTransaction err = json.NewDecoder(resp.Body).Decode(&collectTransaction) diff --git a/client/pools.go b/client/pools.go index b22cc07..9c94f02 100644 --- a/client/pools.go +++ b/client/pools.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" "github.com/maestro-org/go-sdk/utils" @@ -18,6 +19,9 @@ func (c *Client) ListOfRegisteredPools(params *utils.Parameters) (*models.Regist if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var registeredPools models.RegisteredPools err = json.NewDecoder(resp.Body).Decode(®isteredPools) @@ -40,6 +44,9 @@ func (c *Client) StakePoolMintedBlocks( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var poolMintedBlocks models.PoolMintedBlocks err = json.NewDecoder(resp.Body).Decode(&poolMintedBlocks) @@ -62,6 +69,9 @@ func (c *Client) StakePoolDelegators( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var stakePoolDelegators models.StakePoolDelegators err = json.NewDecoder(resp.Body).Decode(&stakePoolDelegators) @@ -84,6 +94,9 @@ func (c *Client) StakePoolHistory( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var stakePoolHistory models.StakePoolHistory err = json.NewDecoder(resp.Body).Decode(&stakePoolHistory) @@ -99,6 +112,9 @@ func (c *Client) StakePoolInformation(poolId string) (*models.StakePoolInformati if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var stakePoolInformation models.StakePoolInformation err = json.NewDecoder(resp.Body).Decode(&stakePoolInformation) @@ -114,6 +130,9 @@ func (c *Client) StakePoolMetadata(poolId string) (*models.StakePoolMetadata, er if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var stakePoolMetadata models.StakePoolMetadata err = json.NewDecoder(resp.Body).Decode(&stakePoolMetadata) @@ -129,6 +148,9 @@ func (c *Client) StakePoolRelays(poolId string) (*models.StakePoolRelays, error) if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var stakePoolRelays models.StakePoolRelays err = json.NewDecoder(resp.Body).Decode(&stakePoolRelays) @@ -145,6 +167,9 @@ func (c *Client) StakePoolUpdates(poolId string) (*models.StakePoolUpdates, erro if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var stakePoolUpdates models.StakePoolUpdates err = json.NewDecoder(resp.Body).Decode(&stakePoolUpdates) diff --git a/client/scripts.go b/client/scripts.go index a67e46a..614fe7f 100644 --- a/client/scripts.go +++ b/client/scripts.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" ) @@ -13,6 +14,9 @@ func (c *Client) ScriptByHash(hash string) (*models.ScriptByHash, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var scriptByHash models.ScriptByHash err = json.NewDecoder(resp.Body).Decode(&scriptByHash) diff --git a/client/transactions.go b/client/transactions.go index 795f1a5..72d81a9 100644 --- a/client/transactions.go +++ b/client/transactions.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "fmt" + "net/http" "github.com/maestro-org/go-sdk/models" "github.com/maestro-org/go-sdk/utils" @@ -14,6 +15,9 @@ func (c *Client) AddressByOutputReference(txHash string, index int) (*models.Bas if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var addressByOutputReference models.BasicResponse err = json.NewDecoder(resp.Body).Decode(&addressByOutputReference) @@ -30,6 +34,9 @@ func (c *Client) SubmitTx(cbor string) (models.BasicResponse, error) { if err != nil { return models.BasicResponse{}, err } + if resp.StatusCode != http.StatusOK { + return models.BasicResponse{}, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var submitTx models.BasicResponse @@ -46,6 +53,9 @@ func (c *Client) TransactionCbor(txHash string) (*models.BasicResponse, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var transactionCbor models.BasicResponse err = json.NewDecoder(resp.Body).Decode(&transactionCbor) @@ -62,6 +72,9 @@ func (c *Client) TransactionDetails(txHash string) (*models.TransactionDetails, if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var transactionDetails models.TransactionDetails err = json.NewDecoder(resp.Body).Decode(&transactionDetails) @@ -86,6 +99,9 @@ func (c *Client) TransactionOutputFromReference( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var transactionOutputFromReference models.TransactionOutputFromReference err = json.NewDecoder(resp.Body).Decode(&transactionOutputFromReference) @@ -109,6 +125,9 @@ func (c *Client) TransactionOutputsFromReferences( if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var transactionOutputsFromReferences models.TransactionOutputsFromReferences err = json.NewDecoder(resp.Body).Decode(&transactionOutputsFromReferences) @@ -129,6 +148,9 @@ func (c *Client) EvaluateTx(txCbor string, AdditionalUtxos ...string) ([]models. if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var redeemerEvals []models.RedeemerEvaluation err = json.NewDecoder(resp.Body).Decode(&redeemerEvals) diff --git a/client/txmanager.go b/client/txmanager.go index d17eab5..fbbcbe2 100644 --- a/client/txmanager.go +++ b/client/txmanager.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io" + "net/http" "github.com/maestro-org/go-sdk/models" ) @@ -15,6 +16,9 @@ func (c *Client) TxManagerHistory() (*[]models.TxManagerState, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var txManagerStates []models.TxManagerState err = json.NewDecoder(resp.Body).Decode(&txManagerStates) @@ -34,6 +38,9 @@ func (c *Client) TxManagerSubmit(txHex string) (string, error) { if err != nil { return "", err } + if resp.StatusCode != http.StatusOK { + return "", fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() bodyBytes, err := io.ReadAll(resp.Body) if err != nil { @@ -53,6 +60,9 @@ func (c *Client) TxManagerSubmitTurbo(txHex string) (string, error) { if err != nil { return "", err } + if resp.StatusCode != http.StatusOK { + return "", fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() bodyBytes, err := io.ReadAll(resp.Body) if err != nil { @@ -68,6 +78,9 @@ func (c *Client) TxManagerState(txHash string) (*models.TxManagerState, error) { if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected error: %d", resp.Body) + } defer resp.Body.Close() var txManagerState models.TxManagerState err = json.NewDecoder(resp.Body).Decode(&txManagerState)