Documentation ¶
Index ¶
- Constants
- Variables
- func AccountArray(arrName string, arr []*types.AccountIdentifier) error
- func AccountBalanceResponse(requestBlock *types.PartialBlockIdentifier, ...) error
- func AccountIdentifier(account *types.AccountIdentifier) error
- func Allow(allowed *types.Allow) error
- func Amount(amount *types.Amount) error
- func AssertUniqueAmounts(amounts []*types.Amount) error
- func BlockIdentifier(blockIdentifier *types.BlockIdentifier) error
- func Coin(coin *types.Coin) error
- func CoinAction(action types.CoinAction) error
- func CoinChange(change *types.CoinChange) error
- func CoinIdentifier(coinIdentifier *types.CoinIdentifier) error
- func Coins(coins []*types.Coin) error
- func ConstructionCombineResponse(response *types.ConstructionCombineResponse) error
- func ConstructionDeriveResponse(response *types.ConstructionDeriveResponse) error
- func ConstructionMetadataResponse(response *types.ConstructionMetadataResponse) error
- func ConstructionPayloadsResponse(response *types.ConstructionPayloadsResponse) error
- func ConstructionPreprocessResponse(response *types.ConstructionPreprocessResponse) error
- func ContainsCurrency(currencies []*types.Currency, currency *types.Currency) bool
- func Currency(currency *types.Currency) error
- func CurveType(curve types.CurveType) error
- func Err(err error) (bool, string)
- func Error(err *types.Error) error
- func Errors(rosettaErrors []*types.Error) error
- func MempoolTransactions(transactions []*types.TransactionIdentifier) error
- func NetworkIdentifier(network *types.NetworkIdentifier) error
- func NetworkListResponse(response *types.NetworkListResponse) error
- func NetworkOptionsResponse(options *types.NetworkOptionsResponse) error
- func NetworkStatusResponse(response *types.NetworkStatusResponse) error
- func OperationIdentifier(identifier *types.OperationIdentifier, index int64) error
- func OperationStatuses(statuses []*types.OperationStatus) error
- func OperationTypes(types []string) error
- func PartialBlockIdentifier(blockIdentifier *types.PartialBlockIdentifier) error
- func Peer(peer *types.Peer) error
- func PublicKey(publicKey *types.PublicKey) error
- func SignatureType(signature types.SignatureType) error
- func Signatures(signatures []*types.Signature) error
- func SigningPayload(signingPayload *types.SigningPayload) error
- func StringArray(arrName string, arr []string) error
- func SubNetworkIdentifier(subNetworkIdentifier *types.SubNetworkIdentifier) error
- func SupportedNetworks(supportedNetworks []*types.NetworkIdentifier) error
- func Timestamp(timestamp int64) error
- func TransactionIdentifier(transactionIdentifier *types.TransactionIdentifier) error
- func TransactionIdentifierResponse(response *types.TransactionIdentifierResponse) error
- func Version(version *types.Version) error
- type Asserter
- func NewClientWithFile(filePath string) (*Asserter, error)
- func NewClientWithOptions(network *types.NetworkIdentifier, ...) (*Asserter, error)
- func NewClientWithResponses(network *types.NetworkIdentifier, networkStatus *types.NetworkStatusResponse, ...) (*Asserter, error)
- func NewServer(supportedOperationTypes []string, historicalBalanceLookup bool, ...) (*Asserter, error)
- func (a *Asserter) AccountBalanceRequest(request *types.AccountBalanceRequest) error
- func (a *Asserter) Block(block *types.Block) error
- func (a *Asserter) BlockRequest(request *types.BlockRequest) error
- func (a *Asserter) BlockTransactionRequest(request *types.BlockTransactionRequest) error
- func (a *Asserter) ClientConfiguration() (*Configuration, error)
- func (a *Asserter) ConstructionCombineRequest(request *types.ConstructionCombineRequest) error
- func (a *Asserter) ConstructionDeriveRequest(request *types.ConstructionDeriveRequest) error
- func (a *Asserter) ConstructionHashRequest(request *types.ConstructionHashRequest) error
- func (a *Asserter) ConstructionMetadataRequest(request *types.ConstructionMetadataRequest) error
- func (a *Asserter) ConstructionParseRequest(request *types.ConstructionParseRequest) error
- func (a *Asserter) ConstructionParseResponse(response *types.ConstructionParseResponse, signed bool) error
- func (a *Asserter) ConstructionPayloadsRequest(request *types.ConstructionPayloadsRequest) error
- func (a *Asserter) ConstructionPreprocessRequest(request *types.ConstructionPreprocessRequest) error
- func (a *Asserter) ConstructionSubmitRequest(request *types.ConstructionSubmitRequest) error
- func (a *Asserter) MempoolTransactionRequest(request *types.MempoolTransactionRequest) error
- func (a *Asserter) MetadataRequest(request *types.MetadataRequest) error
- func (a *Asserter) NetworkRequest(request *types.NetworkRequest) error
- func (a *Asserter) Operation(operation *types.Operation, index int64, construction bool) error
- func (a *Asserter) OperationStatus(status string) error
- func (a *Asserter) OperationSuccessful(operation *types.Operation) (bool, error)
- func (a *Asserter) OperationType(t string) error
- func (a *Asserter) Operations(operations []*types.Operation, construction bool) error
- func (a *Asserter) SupportedNetwork(requestNetwork *types.NetworkIdentifier) error
- func (a *Asserter) Transaction(transaction *types.Transaction) error
- func (a *Asserter) ValidSupportedNetwork(requestNetwork *types.NetworkIdentifier) error
- type Configuration
Constants ¶
const ( // MinUnixEpoch is the unix epoch time in milliseconds of // 01/01/2000 at 12:00:00 AM. MinUnixEpoch = 946713600000 // MaxUnixEpoch is the unix epoch time in milliseconds of // 01/01/2040 at 12:00:00 AM. MaxUnixEpoch = 2209017600000 )
Variables ¶
var ( ErrReturnedBlockHashMismatch = errors.New( "request block hash does not match response block hash", ) ErrReturnedBlockIndexMismatch = errors.New( "request block index does not match response block index", ) AccountBalanceErrs = []error{ ErrReturnedBlockHashMismatch, ErrReturnedBlockIndexMismatch, } ErrAmountValueMissing = errors.New("Amount.Value is missing") ErrAmountIsNotInt = errors.New("Amount.Value is not an integer") ErrAmountCurrencyIsNil = errors.New("Amount.Currency is nil") ErrAmountCurrencySymbolEmpty = errors.New("Amount.Currency.Symbol is empty") ErrAmountCurrencyHasNegDecimals = errors.New("Amount.Currency.Decimals must be >= 0") ErrOperationIdentifierIndexIsNil = errors.New( "Operation.OperationIdentifier.Index is invalid", ) ErrOperationIdentifierIndexOutOfOrder = errors.New( "Operation.OperationIdentifier.Index is out of order", ) ErrOperationIdentifierNetworkIndexInvalid = errors.New( "Operation.OperationIdentifier.NetworkIndex is invalid", ) ErrAccountIsNil = errors.New("Account is nil") ErrAccountAddrMissing = errors.New("Account.Address is missing") ErrAccountSubAccountAddrMissing = errors.New("Account.SubAccount.Address is missing") ErrOperationStatusMissing = errors.New("Operation.Status is missing") ErrOperationStatusInvalid = errors.New("Operation.Status is invalid") ErrOperationTypeInvalid = errors.New("Operation.Type is invalid") ErrOperationIsNil = errors.New("Operation is nil") ErrOperationStatusNotEmptyForConstruction = errors.New( "Operation.Status must be empty for construction", ) ErrRelatedOperationIndexOutOfOrder = errors.New( "related operation has index greater than operation", ) ErrRelatedOperationIndexDuplicate = errors.New("found duplicate related operation index") ErrBlockIdentifierIsNil = errors.New("BlockIdentifier is nil") ErrBlockIdentifierHashMissing = errors.New("BlockIdentifier.Hash is missing") ErrBlockIdentifierIndexIsNeg = errors.New("BlockIdentifier.Index is negative") ErrPartialBlockIdentifierIsNil = errors.New("PartialBlockIdentifier is nil") ErrPartialBlockIdentifierFieldsNotSet = errors.New( "neither PartialBlockIdentifier.Hash nor PartialBlockIdentifier.Index is set", ) ErrTxIdentifierIsNil = errors.New("TransactionIdentifier is nil") ErrTxIdentifierHashMissing = errors.New("TransactionIdentifier.Hash is missing") ErrNoOperationsForConstruction = errors.New("operations cannot be empty for construction") ErrTxIsNil = errors.New("Transaction is nil") ErrTimestampBeforeMin = errors.New("timestamp is before 01/01/2000") ErrTimestampAfterMax = errors.New("timestamp is after 01/01/2040") ErrBlockIsNil = errors.New("Block is nil") ErrBlockHashEqualsParentBlockHash = errors.New( "BlockIdentifier.Hash == ParentBlockIdentifier.Hash", ) ErrBlockIndexPrecedesParentBlockIndex = errors.New( "BlockIdentifier.Index <= ParentBlockIdentifier.Index", ) BlockErrs = []error{ ErrAmountValueMissing, ErrAmountIsNotInt, ErrAmountCurrencyIsNil, ErrAmountCurrencySymbolEmpty, ErrAmountCurrencyHasNegDecimals, ErrOperationIdentifierIndexIsNil, ErrOperationIdentifierIndexOutOfOrder, ErrOperationIdentifierNetworkIndexInvalid, ErrAccountIsNil, ErrAccountAddrMissing, ErrAccountSubAccountAddrMissing, ErrOperationStatusMissing, ErrOperationStatusInvalid, ErrOperationTypeInvalid, ErrOperationIsNil, ErrOperationStatusNotEmptyForConstruction, ErrRelatedOperationIndexOutOfOrder, ErrRelatedOperationIndexDuplicate, ErrBlockIdentifierIsNil, ErrBlockIdentifierHashMissing, ErrBlockIdentifierIndexIsNeg, ErrPartialBlockIdentifierIsNil, ErrPartialBlockIdentifierFieldsNotSet, ErrTxIdentifierIsNil, ErrTxIdentifierHashMissing, ErrNoOperationsForConstruction, ErrTxIsNil, ErrTimestampBeforeMin, ErrTimestampAfterMax, ErrBlockIsNil, ErrBlockHashEqualsParentBlockHash, ErrBlockIndexPrecedesParentBlockIndex, } ErrCoinIsNil = errors.New("coin cannot be nil") ErrCoinDuplicate = errors.New("duplicate coin identifier detected") ErrCoinIdentifierIsNil = errors.New("coin identifier cannot be nil") ErrCoinIdentifierNotSet = errors.New("coin identifier cannot be empty") ErrCoinChangeIsNil = errors.New("coin change cannot be nil") ErrCoinActionInvalid = errors.New("not a valid coin action") CoinErrs = []error{ ErrCoinIsNil, ErrCoinDuplicate, ErrCoinIdentifierIsNil, ErrCoinIdentifierNotSet, ErrCoinChangeIsNil, ErrCoinActionInvalid, } ErrConstructionPreprocessResponseIsNil = errors.New( "ConstructionPreprocessResponse cannot be nil", ) ErrConstructionMetadataResponseIsNil = errors.New( "ConstructionMetadataResponse cannot be nil", ) ErrConstructionMetadataResponseMetadataMissing = errors.New("Metadata is nil") ErrTxIdentifierResponseIsNil = errors.New( "TransactionIdentifierResponse cannot be nil", ) ErrConstructionCombineResponseIsNil = errors.New( "construction combine response cannot be nil", ) ErrSignedTxEmpty = errors.New( "signed transaction cannot be empty", ) ErrConstructionDeriveResponseIsNil = errors.New( "construction derive response cannot be nil", ) ErrConstructionDeriveResponseAddrEmpty = errors.New("address cannot be empty") ErrConstructionParseResponseIsNil = errors.New( "construction parse response cannot be nil", ) ErrConstructionParseResponseOperationsEmpty = errors.New("operations cannot be empty") ErrConstructionParseResponseSignersEmptyOnSignedTx = errors.New( "signers cannot be empty on signed transaction", ) ErrConstructionParseResponseSignersNonEmptyOnUnsignedTx = errors.New( "signers should be empty for unsigned txs", ) ErrConstructionParseResponseSignerEmpty = errors.New("signer cannot be empty string") ErrConstructionParseResponseDuplicateSigner = errors.New("found duplicate signer") ErrConstructionPayloadsResponseIsNil = errors.New( "construction payloads response cannot be nil", ) ErrConstructionPayloadsResponseUnsignedTxEmpty = errors.New( "unsigned transaction cannot be empty", ) ErrConstructionPayloadsResponsePayloadsEmpty = errors.New("signing payloads cannot be empty") ErrPublicKeyIsNil = errors.New("PublicKey cannot be nil") ErrPublicKeyBytesEmpty = errors.New("public key bytes cannot be empty") ErrCurveTypeNotSupported = errors.New("not a supported CurveType") ErrSigningPayloadIsNil = errors.New("signing payload cannot be nil") ErrSigningPayloadAddrEmpty = errors.New( "signing payload address cannot be empty", ) ErrSigningPayloadBytesEmpty = errors.New( "signing payload bytes cannot be empty", ) ErrSignaturesEmpty = errors.New("signatures cannot be empty") ErrSignaturesReturnedSigMismatch = errors.New( "requested signature type does not match returned signature type", ) ErrSignatureBytesEmpty = errors.New("signature bytes cannot be empty") ErrSignatureTypeNotSupported = errors.New("not a supported SignatureType") ConstructionErrs = []error{ ErrConstructionPreprocessResponseIsNil, ErrConstructionMetadataResponseIsNil, ErrConstructionMetadataResponseMetadataMissing, ErrTxIdentifierResponseIsNil, ErrConstructionCombineResponseIsNil, ErrSignedTxEmpty, ErrConstructionDeriveResponseIsNil, ErrConstructionDeriveResponseAddrEmpty, ErrConstructionParseResponseIsNil, ErrConstructionParseResponseOperationsEmpty, ErrConstructionParseResponseSignersEmptyOnSignedTx, ErrConstructionParseResponseSignersNonEmptyOnUnsignedTx, ErrConstructionParseResponseSignerEmpty, ErrConstructionPayloadsResponseIsNil, ErrConstructionPayloadsResponseUnsignedTxEmpty, ErrConstructionPayloadsResponsePayloadsEmpty, ErrPublicKeyIsNil, ErrPublicKeyBytesEmpty, ErrCurveTypeNotSupported, ErrSigningPayloadIsNil, ErrSigningPayloadAddrEmpty, ErrSigningPayloadBytesEmpty, ErrSignaturesEmpty, ErrSignaturesReturnedSigMismatch, ErrSignatureBytesEmpty, ErrSignatureTypeNotSupported, } ErrSubNetworkIdentifierInvalid = errors.New( "NetworkIdentifier.SubNetworkIdentifier.Network is missing", ) ErrNetworkIdentifierIsNil = errors.New("NetworkIdentifier is nil") ErrNetworkIdentifierBlockchainMissing = errors.New("NetworkIdentifier.Blockchain is missing") ErrNetworkIdentifierNetworkMissing = errors.New("NetworkIdentifier.Network is missing") ErrPeerIDMissing = errors.New("Peer.PeerID is missing") ErrVersionIsNil = errors.New("version is nil") ErrVersionNodeVersionMissing = errors.New("Version.NodeVersion is missing") ErrVersionMiddlewareVersionMissing = errors.New("Version.MiddlewareVersion is missing") ErrNetworkStatusResponseIsNil = errors.New("network status response is nil") ErrNoAllowedOperationStatuses = errors.New("no Allow.OperationStatuses found") ErrNoSuccessfulAllowedOperationStatuses = errors.New( "no successful Allow.OperationStatuses found", ) ErrErrorIsNil = errors.New("Error is nil") ErrErrorCodeIsNeg = errors.New("Error.Code is negative") ErrErrorMessageMissing = errors.New("Error.Message is missing") ErrErrorCodeUsedMultipleTimes = errors.New("error code used multiple times") ErrAllowIsNil = errors.New("Allow is nil") ErrNetworkOptionsResponseIsNil = errors.New("options is nil") ErrNetworkListResponseIsNil = errors.New("NetworkListResponse is nil") ErrNetworkListResponseNetworksContinsDuplicates = errors.New( "NetworkListResponse.Networks contains duplicates", ) NetworkErrs = []error{ ErrSubNetworkIdentifierInvalid, ErrNetworkIdentifierIsNil, ErrNetworkIdentifierBlockchainMissing, ErrNetworkIdentifierNetworkMissing, ErrPeerIDMissing, ErrVersionIsNil, ErrVersionNodeVersionMissing, ErrVersionMiddlewareVersionMissing, ErrNetworkStatusResponseIsNil, ErrNoAllowedOperationStatuses, ErrNoSuccessfulAllowedOperationStatuses, ErrErrorIsNil, ErrErrorCodeIsNeg, ErrErrorMessageMissing, ErrErrorCodeUsedMultipleTimes, ErrAllowIsNil, ErrNetworkOptionsResponseIsNil, ErrNetworkListResponseIsNil, ErrNetworkListResponseNetworksContinsDuplicates, } ErrNoSupportedNetworks = errors.New( "no supported networks", ) ErrSupportedNetworksDuplicate = errors.New( "supported network duplicate", ) ErrRequestedNetworkNotSupported = errors.New( "requestNetwork not supported", ) ErrAccountBalanceRequestIsNil = errors.New( "AccountBalanceRequest is nil", ) ErrAccountBalanceRequestHistoricalBalanceLookupNotSupported = errors.New( "historical balance lookup is not supported", ) ErrBlockRequestIsNil = errors.New("BlockRequest is nil") ErrBlockTransactionRequestIsNil = errors.New("BlockTransactionRequest is nil") ErrConstructionMetadataRequestIsNil = errors.New("ConstructionMetadataRequest is nil") ErrConstructionMetadataRequestOptionsIsNil = errors.New( "ConstructionMetadataRequest.Options is nil", ) ErrConstructionSubmitRequestIsNil = errors.New("ConstructionSubmitRequest is nil") ErrConstructionSubmitRequestSignedTxEmpty = errors.New( "ConstructionSubmitRequest.SignedTransaction is empty", ) ErrMempoolTransactionRequestIsNil = errors.New( "MempoolTransactionRequest is nil", ) ErrMetadataRequestIsNil = errors.New( "MetadataRequest is nil", ) ErrNetworkRequestIsNil = errors.New( "NetworkRequest is nil", ) ErrConstructionDeriveRequestIsNil = errors.New( "ConstructionDeriveRequest is nil", ) ErrConstructionPreprocessRequestIsNil = errors.New( "ConstructionPreprocessRequest is nil", ) ErrConstructionPreprocessRequestSuggestedFeeMultiplierIsNeg = errors.New( "suggested fee multiplier cannot be less than 0", ) ErrConstructionPayloadsRequestIsNil = errors.New("ConstructionPayloadsRequest is nil") ErrConstructionCombineRequestIsNil = errors.New("ConstructionCombineRequest is nil") ErrConstructionCombineRequestUnsignedTxEmpty = errors.New("UnsignedTransaction cannot be empty") ErrConstructionHashRequestIsNil = errors.New("ConstructionHashRequest is nil") ErrConstructionHashRequestSignedTxEmpty = errors.New("SignedTransaction cannot be empty") ErrConstructionParseRequestIsNil = errors.New("ConstructionParseRequest is nil") ErrConstructionParseRequestEmpty = errors.New("Transaction cannot be empty") ServerErrs = []error{ ErrNoSupportedNetworks, ErrSupportedNetworksDuplicate, ErrRequestedNetworkNotSupported, ErrAccountBalanceRequestIsNil, ErrAccountBalanceRequestHistoricalBalanceLookupNotSupported, ErrBlockRequestIsNil, ErrBlockTransactionRequestIsNil, ErrConstructionMetadataRequestIsNil, ErrConstructionMetadataRequestOptionsIsNil, ErrConstructionSubmitRequestIsNil, ErrConstructionSubmitRequestSignedTxEmpty, ErrMempoolTransactionRequestIsNil, ErrMetadataRequestIsNil, ErrNetworkRequestIsNil, ErrConstructionDeriveRequestIsNil, ErrConstructionPreprocessRequestIsNil, ErrConstructionPreprocessRequestSuggestedFeeMultiplierIsNeg, ErrConstructionPayloadsRequestIsNil, ErrConstructionCombineRequestIsNil, ErrConstructionCombineRequestUnsignedTxEmpty, ErrConstructionHashRequestIsNil, ErrConstructionHashRequestSignedTxEmpty, ErrConstructionParseRequestIsNil, ErrConstructionParseRequestEmpty, } )
Named error types for Asserter errors
var ( // ErrAsserterNotInitialized is returned when some call in the asserter // package requires the asserter to be initialized first. ErrAsserterNotInitialized = errors.New("asserter not initialized") )
Functions ¶
func AccountArray ¶ added in v0.4.1
func AccountArray(arrName string, arr []*types.AccountIdentifier) error
AccountArray ensures all *types.AccountIdentifier in an array are valid and not duplicates.
func AccountBalanceResponse ¶ added in v0.1.5
func AccountBalanceResponse( requestBlock *types.PartialBlockIdentifier, response *types.AccountBalanceResponse, ) error
AccountBalanceResponse returns an error if the provided types.BlockIdentifier is invalid, if the requestBlock is not nil and not equal to the response block, or if the same currency is present in multiple amounts.
func AccountIdentifier ¶
func AccountIdentifier(account *types.AccountIdentifier) error
AccountIdentifier returns an error if a types.AccountIdentifier is missing an address or a provided SubAccount is missing an identifier.
func AssertUniqueAmounts ¶ added in v0.4.1
AssertUniqueAmounts returns an error if a slice of types.Amount is invalid. It is considered invalid if the same currency is returned multiple times (these shoould be consolidated) or if a types.Amount is considered invalid.
func BlockIdentifier ¶
func BlockIdentifier(blockIdentifier *types.BlockIdentifier) error
BlockIdentifier ensures a types.BlockIdentifier is well-formatted.
func CoinAction ¶ added in v0.3.3
func CoinAction(action types.CoinAction) error
CoinAction returns an error if the provided types.CoinAction is invalid.
func CoinChange ¶ added in v0.3.3
func CoinChange(change *types.CoinChange) error
CoinChange returns an error if the provided *types.CoinChange is invalid.
func CoinIdentifier ¶ added in v0.3.3
func CoinIdentifier(coinIdentifier *types.CoinIdentifier) error
CoinIdentifier returns an error if the provided *types.CoinIdentifier is invalid.
func Coins ¶ added in v0.3.3
Coins returns an error if the provided []*types.Coin is invalid. If there are any duplicate identifiers, this function will also return an error.
func ConstructionCombineResponse ¶ added in v0.3.0
func ConstructionCombineResponse( response *types.ConstructionCombineResponse, ) error
ConstructionCombineResponse returns an error if a *types.ConstructionCombineResponse does not have a populated SignedTransaction.
func ConstructionDeriveResponse ¶ added in v0.3.0
func ConstructionDeriveResponse( response *types.ConstructionDeriveResponse, ) error
ConstructionDeriveResponse returns an error if a *types.ConstructionDeriveResponse does not have a populated Address.
func ConstructionMetadataResponse ¶ added in v0.3.0
func ConstructionMetadataResponse( response *types.ConstructionMetadataResponse, ) error
ConstructionMetadataResponse returns an error if the metadata is not a JSON object.
func ConstructionPayloadsResponse ¶ added in v0.3.0
func ConstructionPayloadsResponse( response *types.ConstructionPayloadsResponse, ) error
ConstructionPayloadsResponse returns an error if a *types.ConstructionPayloadsResponse does not have an UnsignedTransaction or has no valid *SigningPaylod.
func ConstructionPreprocessResponse ¶ added in v0.4.1
func ConstructionPreprocessResponse( response *types.ConstructionPreprocessResponse, ) error
ConstructionPreprocessResponse returns an error if the request public keys are not valid AccountIdentifiers.
func ContainsCurrency ¶ added in v0.2.0
ContainsCurrency returns a boolean indicating if a *types.Currency is contained within a slice of *types.Currency. The check for equality takes into account everything within the types.Currency struct (including currency.Metadata).
func CurveType ¶ added in v0.3.0
CurveType returns an error if the curve is not a valid types.CurveType.
func Err ¶ added in v0.4.1
Err takes an error as an argument and returns whether or not the error is one thrown by the asserter along with the specific source of the error
func Errors ¶ added in v0.0.4
Errors ensures each types.Error in a slice is valid and that there is no error code collision.
func MempoolTransactions ¶
func MempoolTransactions( transactions []*types.TransactionIdentifier, ) error
MempoolTransactions returns an error if any types.TransactionIdentifier returns is missing a hash. The correctness of each populated MempoolTransaction is asserted by Transaction.
func NetworkIdentifier ¶
func NetworkIdentifier(network *types.NetworkIdentifier) error
NetworkIdentifier ensures a types.NetworkIdentifier has a valid blockchain and network.
func NetworkListResponse ¶ added in v0.1.2
func NetworkListResponse(response *types.NetworkListResponse) error
NetworkListResponse ensures a types.NetworkListResponse object is valid.
func NetworkOptionsResponse ¶ added in v0.1.2
func NetworkOptionsResponse(options *types.NetworkOptionsResponse) error
NetworkOptionsResponse ensures a types.NetworkOptionsResponse object is valid.
func NetworkStatusResponse ¶
func NetworkStatusResponse(response *types.NetworkStatusResponse) error
NetworkStatusResponse ensures any types.NetworkStatusResponse is valid.
func OperationIdentifier ¶
func OperationIdentifier( identifier *types.OperationIdentifier, index int64, ) error
OperationIdentifier returns an error if index of the types.Operation is out-of-order or if the NetworkIndex is invalid.
func OperationStatuses ¶
func OperationStatuses(statuses []*types.OperationStatus) error
OperationStatuses ensures all items in Options.Allow.OperationStatuses are valid and that there exists at least 1 successful status.
func OperationTypes ¶ added in v0.1.6
OperationTypes ensures all items in Options.Allow.OperationStatuses are valid and that there are no repeats.
func PartialBlockIdentifier ¶ added in v0.1.0
func PartialBlockIdentifier(blockIdentifier *types.PartialBlockIdentifier) error
PartialBlockIdentifier ensures a types.PartialBlockIdentifier is well-formatted.
func PublicKey ¶ added in v0.3.0
PublicKey returns an error if the *types.PublicKey is nil, is not valid hex, or has an undefined CurveType.
func SignatureType ¶ added in v0.3.0
func SignatureType( signature types.SignatureType, ) error
SignatureType returns an error if signature is not a valid types.SignatureType.
func Signatures ¶ added in v0.3.0
Signatures returns an error if any *types.Signature is invalid.
func SigningPayload ¶ added in v0.3.0
func SigningPayload( signingPayload *types.SigningPayload, ) error
SigningPayload returns an error if a *types.SigningPayload is nil, has an empty address, has invlaid hex, or has an invalid SignatureType (if populated).
func StringArray ¶
StringArray ensures all strings in an array are non-empty strings and not duplicates.
func SubNetworkIdentifier ¶
func SubNetworkIdentifier(subNetworkIdentifier *types.SubNetworkIdentifier) error
SubNetworkIdentifier asserts a types.SubNetworkIdentifer is valid (if not nil).
func SupportedNetworks ¶ added in v0.1.6
func SupportedNetworks(supportedNetworks []*types.NetworkIdentifier) error
SupportedNetworks returns an error if there is an invalid types.NetworkIdentifier or there is a duplicate.
func TransactionIdentifier ¶
func TransactionIdentifier( transactionIdentifier *types.TransactionIdentifier, ) error
TransactionIdentifier returns an error if a types.TransactionIdentifier has an invalid hash.
func TransactionIdentifierResponse ¶ added in v0.3.3
func TransactionIdentifierResponse( response *types.TransactionIdentifierResponse, ) error
TransactionIdentifierResponse returns an error if the types.TransactionIdentifier in the response is not valid.
Types ¶
type Asserter ¶
type Asserter struct {
// contains filtered or unexported fields
}
Asserter contains all logic to perform static validation on Rosetta Server responses.
func NewClientWithFile ¶ added in v0.1.6
NewClientWithFile constructs a new Asserter using a specification file instead of responses. This can be useful for running reliable systems that error when updates to the server (more error types, more operations, etc.) significantly change how to parse the chain. The filePath provided is parsed relative to the current directory.
func NewClientWithOptions ¶ added in v0.1.6
func NewClientWithOptions( network *types.NetworkIdentifier, genesisBlockIdentifier *types.BlockIdentifier, operationTypes []string, operationStatuses []*types.OperationStatus, errors []*types.Error, ) (*Asserter, error)
NewClientWithOptions constructs a new Asserter using the provided arguments instead of using a NetworkStatusResponse and a NetworkOptionsResponse.
func NewClientWithResponses ¶ added in v0.1.6
func NewClientWithResponses( network *types.NetworkIdentifier, networkStatus *types.NetworkStatusResponse, networkOptions *types.NetworkOptionsResponse, ) (*Asserter, error)
NewClientWithResponses constructs a new Asserter from a NetworkStatusResponse and NetworkOptionsResponse.
func NewServer ¶ added in v0.1.6
func NewServer( supportedOperationTypes []string, historicalBalanceLookup bool, supportedNetworks []*types.NetworkIdentifier, ) (*Asserter, error)
NewServer constructs a new Asserter for use in the server package.
func (*Asserter) AccountBalanceRequest ¶ added in v0.1.6
func (a *Asserter) AccountBalanceRequest(request *types.AccountBalanceRequest) error
AccountBalanceRequest ensures that a types.AccountBalanceRequest is well-formatted.
func (*Asserter) BlockRequest ¶ added in v0.1.6
func (a *Asserter) BlockRequest(request *types.BlockRequest) error
BlockRequest ensures that a types.BlockRequest is well-formatted.
func (*Asserter) BlockTransactionRequest ¶ added in v0.1.6
func (a *Asserter) BlockTransactionRequest(request *types.BlockTransactionRequest) error
BlockTransactionRequest ensures that a types.BlockTransactionRequest is well-formatted.
func (*Asserter) ClientConfiguration ¶ added in v0.1.6
func (a *Asserter) ClientConfiguration() (*Configuration, error)
ClientConfiguration returns all variables currently set in an Asserter. This function will error if it is called on an uninitialized asserter.
func (*Asserter) ConstructionCombineRequest ¶ added in v0.3.0
func (a *Asserter) ConstructionCombineRequest(request *types.ConstructionCombineRequest) error
ConstructionCombineRequest ensures that a types.ConstructionCombineRequest is well-formatted.
func (*Asserter) ConstructionDeriveRequest ¶ added in v0.3.0
func (a *Asserter) ConstructionDeriveRequest(request *types.ConstructionDeriveRequest) error
ConstructionDeriveRequest ensures that a types.ConstructionDeriveRequest is well-formatted.
func (*Asserter) ConstructionHashRequest ¶ added in v0.3.0
func (a *Asserter) ConstructionHashRequest(request *types.ConstructionHashRequest) error
ConstructionHashRequest ensures that a types.ConstructionHashRequest is well-formatted.
func (*Asserter) ConstructionMetadataRequest ¶ added in v0.1.6
func (a *Asserter) ConstructionMetadataRequest(request *types.ConstructionMetadataRequest) error
ConstructionMetadataRequest ensures that a types.ConstructionMetadataRequest is well-formatted.
func (*Asserter) ConstructionParseRequest ¶ added in v0.3.0
func (a *Asserter) ConstructionParseRequest(request *types.ConstructionParseRequest) error
ConstructionParseRequest ensures that a types.ConstructionParseRequest is well-formatted.
func (*Asserter) ConstructionParseResponse ¶ added in v0.3.0
func (a *Asserter) ConstructionParseResponse( response *types.ConstructionParseResponse, signed bool, ) error
ConstructionParseResponse returns an error if a *types.ConstructionParseResponse does not have a valid set of operations or if the signers is empty.
func (*Asserter) ConstructionPayloadsRequest ¶ added in v0.3.0
func (a *Asserter) ConstructionPayloadsRequest(request *types.ConstructionPayloadsRequest) error
ConstructionPayloadsRequest ensures that a types.ConstructionPayloadsRequest is well-formatted.
func (*Asserter) ConstructionPreprocessRequest ¶ added in v0.3.0
func (a *Asserter) ConstructionPreprocessRequest( request *types.ConstructionPreprocessRequest, ) error
ConstructionPreprocessRequest ensures that a types.ConstructionPreprocessRequest is well-formatted.
func (*Asserter) ConstructionSubmitRequest ¶ added in v0.1.6
func (a *Asserter) ConstructionSubmitRequest(request *types.ConstructionSubmitRequest) error
ConstructionSubmitRequest ensures that a types.ConstructionSubmitRequest is well-formatted.
func (*Asserter) MempoolTransactionRequest ¶ added in v0.1.6
func (a *Asserter) MempoolTransactionRequest(request *types.MempoolTransactionRequest) error
MempoolTransactionRequest ensures that a types.MempoolTransactionRequest is well-formatted.
func (*Asserter) MetadataRequest ¶ added in v0.1.6
func (a *Asserter) MetadataRequest(request *types.MetadataRequest) error
MetadataRequest ensures that a types.MetadataRequest is well-formatted.
func (*Asserter) NetworkRequest ¶ added in v0.1.6
func (a *Asserter) NetworkRequest(request *types.NetworkRequest) error
NetworkRequest ensures that a types.NetworkRequest is well-formatted.
func (*Asserter) Operation ¶
Operation ensures a types.Operation has a valid type, status, and amount.
func (*Asserter) OperationStatus ¶ added in v0.1.6
OperationStatus returns an error if an operation.Status is not valid.
func (*Asserter) OperationSuccessful ¶
OperationSuccessful returns a boolean indicating if a types.Operation is successful and should be applied in a transaction. This should only be called AFTER an operation has been validated.
func (*Asserter) OperationType ¶ added in v0.1.6
OperationType returns an error if an operation.Type is not valid.
func (*Asserter) Operations ¶ added in v0.3.0
Operations returns an error if any *types.Operation in a []*types.Operation is invalid.
func (*Asserter) SupportedNetwork ¶ added in v0.1.6
func (a *Asserter) SupportedNetwork( requestNetwork *types.NetworkIdentifier, ) error
SupportedNetwork returns a boolean indicating if the requestNetwork is allowed. This should be called after the requestNetwork is asserted.
func (*Asserter) Transaction ¶
func (a *Asserter) Transaction( transaction *types.Transaction, ) error
Transaction returns an error if the types.TransactionIdentifier is invalid, if any types.Operation within the types.Transaction is invalid, or if any operation index is reused within a transaction.
func (*Asserter) ValidSupportedNetwork ¶ added in v0.3.0
func (a *Asserter) ValidSupportedNetwork( requestNetwork *types.NetworkIdentifier, ) error
ValidSupportedNetwork returns an error if a types.NetworkIdentifier is not valid or not supported.
type Configuration ¶ added in v0.1.7
type Configuration struct { NetworkIdentifier *types.NetworkIdentifier `json:"network_identifier"` GenesisBlockIdentifier *types.BlockIdentifier `json:"genesis_block_identifier"` AllowedOperationTypes []string `json:"allowed_operation_types"` AllowedOperationStatuses []*types.OperationStatus `json:"allowed_operation_statuses"` AllowedErrors []*types.Error `json:"allowed_errors"` }
Configuration is the static configuration of an Asserter. This configuration can be exported by the Asserter and used to instantiate an Asserter.