diff --git a/.circleci/config.yml b/.circleci/config.yml index 477a72a5..a2dd283e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ version: 2.1 executors: default: docker: - - image: circleci/golang:1.13 + - image: circleci/golang:1.15 user: root # go directory is owned by root working_directory: /go/src/github.com/coinbase/rosetta-sdk-go environment: @@ -51,7 +51,7 @@ jobs: name: default steps: - *fast-checkout - - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 + - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.32.2 - run: make lint check-license: executor: diff --git a/asserter/errors.go b/asserter/errors.go index 7e465625..7cc4fc55 100644 --- a/asserter/errors.go +++ b/asserter/errors.go @@ -20,20 +20,14 @@ import ( utils "github.com/coinbase/rosetta-sdk-go/errors" ) -// Named error types for Asserter errors var ( - ///////////////////// - /* ASSERTER ERRORS */ - ///////////////////// - // ErrAsserterNotInitialized is returned when some call in the asserter // package requires the asserter to be initialized first. ErrAsserterNotInitialized = errors.New("asserter not initialized") +) - ////////////////////////////////// - /* ACCOUNT BALANCE QUERY ERRORS */ - ////////////////////////////////// - +// Account Balance Errors +var ( ErrReturnedBlockHashMismatch = errors.New( "request block hash does not match response block hash", ) @@ -45,11 +39,10 @@ var ( ErrReturnedBlockHashMismatch, ErrReturnedBlockIndexMismatch, } +) - ////////////////// - /* BLOCK ERRORS */ - ////////////////// - +// Block Errors +var ( ErrAmountValueMissing = errors.New("Amount.Value is missing") ErrAmountIsNotInt = errors.New("Amount.Value is not an integer") ErrAmountCurrencyIsNil = errors.New("Amount.Currency is nil") @@ -133,11 +126,10 @@ var ( ErrBlockHashEqualsParentBlockHash, ErrBlockIndexPrecedesParentBlockIndex, } +) - ///////////////// - /* COIN ERRORS */ - ///////////////// - +// Coin Errors +var ( ErrCoinIsNil = errors.New("coin cannot be nil") ErrCoinDuplicate = errors.New("duplicate coin identifier detected") ErrCoinIdentifierIsNil = errors.New("coin identifier cannot be nil") @@ -153,11 +145,10 @@ var ( ErrCoinChangeIsNil, ErrCoinActionInvalid, } +) - ///////////////////////// - /* CONSTRUCTION ERRORS */ - ///////////////////////// - +// Construction Errors +var ( ErrConstructionPreprocessResponseIsNil = errors.New( "ConstructionPreprocessResponse cannot be nil", ) @@ -250,11 +241,10 @@ var ( ErrSignatureBytesZero, ErrSignatureTypeNotSupported, } +) - //////////////////// - /* NETWORK ERRORS */ - //////////////////// - +// Network Errors +var ( ErrSubNetworkIdentifierInvalid = errors.New( "NetworkIdentifier.SubNetworkIdentifier.Network is missing", ) @@ -318,11 +308,10 @@ var ( ErrBalanceExemptionNoHistoricalLookup, ErrTimestampStartIndexInvalid, } +) - /////////////////// - /* SERVER ERRORS */ - /////////////////// - +// Server Errors +var ( ErrNoSupportedNetworks = errors.New( "no supported networks", ) @@ -422,11 +411,10 @@ var ( ErrMaxBlockInvalid, ErrDuplicateCurrency, } +) - /////////////////// - /* EVENTS ERRORS */ - /////////////////// - +// Events Errors +var ( ErrMaxSequenceInvalid = errors.New("max sequence invalid") ErrSequenceInvalid = errors.New("sequence invalid") ErrBlockEventTypeInvalid = errors.New("block event type invalid") @@ -438,20 +426,19 @@ var ( ErrBlockEventTypeInvalid, ErrSequenceOutOfOrder, } +) - /////////////////// - /* SEARCH ERRORS */ - /////////////////// - +// Search Errors +var ( ErrNextOffsetInvalid = errors.New("next offset invalid") SearchErrs = []error{ ErrNextOffsetInvalid, } +) - /////////////////// - /* ERROR ERRORS */ - /////////////////// +// Error Errors +var ( ErrErrorIsNil = errors.New("Error is nil") ErrErrorCodeIsNeg = errors.New("Error.Code is negative") ErrErrorMessageMissing = errors.New("Error.Message is missing") diff --git a/client/configuration.go b/client/configuration.go index e617d568..bb1dd0f6 100644 --- a/client/configuration.go +++ b/client/configuration.go @@ -137,9 +137,9 @@ func (c *Configuration) ServerURL(index int, variables map[string]string) (strin variable.EnumValues, ) } - url = strings.Replace(url, "{"+name+"}", value, -1) + url = strings.ReplaceAll(url, "{"+name+"}", value) } else { - url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) + url = strings.ReplaceAll(url, "{"+name+"}", variable.DefaultValue) } } return url, nil diff --git a/parser/errors.go b/parser/errors.go index 963f1874..5d32062c 100644 --- a/parser/errors.go +++ b/parser/errors.go @@ -20,11 +20,8 @@ import ( utils "github.com/coinbase/rosetta-sdk-go/errors" ) -// Named error types for Parser errors +// Intent Errors var ( - /////////////////// - /* INTENT ERRORS */ - /////////////////// ErrExpectedOperationAccountMismatch = errors.New( "intended account did not match observed account", ) @@ -46,10 +43,10 @@ var ( ErrExpectedSignerUnexpectedSigner, ErrExpectedSignerMissing, } +) - ///////////////////////////// - /* MATCH OPERATIONS ERRORS */ - ///////////////////////////// +// Match Operations Errors +var ( ErrAccountMatchAccountMissing = errors.New("account is missing") ErrAccountMatchSubAccountMissing = errors.New("SubAccountIdentifier.Address is missing") ErrAccountMatchSubAccountPopulated = errors.New("SubAccount is populated") diff --git a/parser/match_operations.go b/parser/match_operations.go index 21bd3138..c45d5af3 100644 --- a/parser/match_operations.go +++ b/parser/match_operations.go @@ -178,7 +178,7 @@ func metadataMatch(reqs []*MetadataDescription, metadata map[string]interface{}) // accountMatch returns an error if a *types.AccountIdentifier does not meet // an *AccountDescription. func accountMatch(req *AccountDescription, account *types.AccountIdentifier) error { - if req == nil { //anything is ok + if req == nil { // anything is ok return nil } diff --git a/storage/errors.go b/storage/errors.go index a31fa6a0..2a99455b 100644 --- a/storage/errors.go +++ b/storage/errors.go @@ -20,12 +20,8 @@ import ( utils "github.com/coinbase/rosetta-sdk-go/errors" ) -// Named error types for Storage errors +// Badger Storage Errors var ( - //////////////////// - /* BADGER STORAGE */ - //////////////////// - ErrDatabaseOpenFailed = errors.New("unable to open database") ErrCompressorLoadFailed = errors.New("unable to load compressor") ErrDBCloseFailed = errors.New("unable to close database") @@ -71,11 +67,10 @@ var ( ErrTrainZSTDFailed, ErrWalkFilesFailed, } +) - /////////////////////// - /* BROADCAST STORAGE */ - /////////////////////// - +// Broadcast Storage Errors +var ( ErrBroadcastTxStale = errors.New("unable to handle stale transaction") ErrBroadcastTxConfirmed = errors.New( "unable to handle confirmed transaction", @@ -137,11 +132,10 @@ var ( ErrBroadcastCommitDeleteFailed, ErrBroadcastPerformFailed, } +) - ////////////////// - /* COIN STORAGE */ - ////////////////// - +// Coin Storage Errors +var ( ErrCoinQueryFailed = errors.New("unable to query for coin") ErrCoinDecodeFailed = errors.New("unable to decode coin") ErrCoinGetFailed = errors.New("unable to get coin") @@ -187,11 +181,10 @@ var ( ErrCoinParseFailed, ErrCoinImportFailed, } +) - //////////////// - /* COMPRESSOR */ - //////////////// - +// Compressor Errors +var ( ErrLoadDictFailed = errors.New("unable to load dictionary") ErrObjectEncodeFailed = errors.New("unable to encode object") ErrRawCompressFailed = errors.New("unable to compress raw bytes") @@ -215,11 +208,10 @@ var ( ErrReaderCloseFailed, ErrCopyBlockFailed, } +) - ///////////////// - /* JOB STORAGE */ - ///////////////// - +// Job Storage Errors +var ( ErrJobsGetAllFailed = errors.New("unable to get all jobs") ErrJobIdentifierDecodeFailed = errors.New("unable to decode existing identifier") ErrJobGetFailed = errors.New("unable to get job") @@ -259,11 +251,10 @@ var ( ErrJobDoesNotExist, ErrJobDecodeFailed, } +) - ///////////////// - /* KEY STORAGE */ - ///////////////// - +// Key Storage Errors +var ( // ErrAddrExists is returned when key storage already // contains an address. ErrAddrExists = errors.New("address already exists") @@ -306,11 +297,10 @@ var ( ErrAddrImportFailed, ErrPrefundedAcctStoreFailed, } +) - ///////////////////// - /* BALANCE STORAGE */ - ///////////////////// - +// Balance Storage Errors +var ( // ErrNegativeBalance is returned when an account // balance goes negative as the result of an operation. ErrNegativeBalance = errors.New("negative balance") @@ -339,11 +329,10 @@ var ( ErrBlockNil, ErrAccountMissing, } +) - /////////////////// - /* BLOCK STORAGE */ - /////////////////// - +// Block Storage Errors +var ( // ErrHeadBlockNotFound is returned when there is no // head block found in BlockStorage. ErrHeadBlockNotFound = errors.New("head block not found") diff --git a/templates/client/configuration.mustache b/templates/client/configuration.mustache index a62e5748..a985dd15 100644 --- a/templates/client/configuration.mustache +++ b/templates/client/configuration.mustache @@ -157,9 +157,9 @@ func (c *Configuration) ServerUrl(index int, variables map[string]string) (strin if !found { return "", fmt.Errorf("The variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) } - url = strings.Replace(url, "{"+name+"}", value, -1) + url = strings.ReplaceAll(url, "{"+name+"}", value) } else { - url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) + url = strings.ReplaceAll(url, "{"+name+"}", variable.DefaultValue) } } return url, nil