package
0.8.9
Repository: https://github.com/coinbase/rosetta-sdk-go.git
Documentation: pkg.go.dev

# README

Asserter

GoDoc

The Asserter package is used to validate the correctness of Mesh types. It is important to note that this validation only ensures that required fields are populated, fields are in the correct format, and transaction operations only contain types and statuses specified in the /network/status endpoint.

If you want more intensive validation, try running the Mesh CLI.

Installation

go get github.com/coinbase/mesh-sdk-go/asserter

Validation file

Asserter package also allows you to specify a validation file which can be used to have a stricter validation against your implementation.

A simple validation files looks like this. Let's break it down and see what it means

"enabled": true

Specifies if we want to enable this validation or not.

"chain_type": "account",

Specify the chain type. Supported types are account and utxo. Right now we only support account based implementation for validation using this file.

"payment": {
  "name": "PAYMENT",
  "operation": {
    "count": 2,
    "should_balance": true
  }
},

This first validation will validate payment or transaction type. The payment object is defined below

  • name: The string used for defining a payment or transaction
  • operation:
    • count: Count of payment operations (defined by name) which should be present in the transaction. If the number is -1, then we won't validate the count
    • should_balance: If the sum total of the amount defined in the all the operations (defined by name) in a particular transaction should add up to 0 or not. This is really helpful to validate a debit and credit operation in the implementation
"fee": {
  "name": "FEE",
  "operation": {
    "count": 1,
    "should_balance": false
  }
}

Similar to payment type we have fee type. The fields here have the same usage as above.


NOTE

Right now we only support payment and fee operation type with count and total balance match. We will keep adding more validations to it.


# Functions

AccountArray ensures all *types.AccountIdentifier in an array are valid and not duplicates.
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.
AccountCoinsResponse returns an error if the provided *types.AccountCoinsResponse is invalid.
AccountIdentifier returns an error if a types.AccountIdentifier is missing an address or a provided SubAccount is missing an identifier.
Allow ensures a types.Allow object is valid.
Amount ensures a types.Amount has an integer value, specified precision, and symbol.
AssertUniqueAmounts returns an error if a slice of types.Amount is invalid.
BalanceExemptions ensures []*types.BalanceExemption is valid.
BlockEvent ensures a *types.BlockEvent is valid.
BlockIdentifier ensures a types.BlockIdentifier is well-formatted.
BytesArrayZero returns a boolean indicating if all elements in an array are 0.
CallMethods ensures Allow.CallMethods are valid.
Coin returns an error if the provided *types.Coin is invalid.
CoinAction returns an error if the provided types.CoinAction is invalid.
CoinChange returns an error if the provided *types.CoinChange is invalid.
CoinIdentifier returns an error if the provided *types.CoinIdentifier is invalid.
Coins returns an error if the provided []*types.Coin is invalid.
ConstructionCombineResponse returns an error if a *types.ConstructionCombineResponse does not have a populated SignedTransaction.
ConstructionDeriveResponse returns an error if a *types.ConstructionDeriveResponse does not have a populated Address.
ConstructionMetadataResponse returns an error if the metadata is not a JSON object.
ConstructionPayloadsResponse returns an error if a *types.ConstructionPayloadsResponse does not have an UnsignedTransaction or has no valid *SigningPaylod.
ConstructionPreprocessResponse returns an error if the request public keys are not valid AccountIdentifiers.
ContainsCurrency returns a boolean indicating if a *types.Currency is contained within a slice of *types.Currency.
ContainsDuplicateCurrency retruns a boolean indicating if an array of *types.Currency contains any duplicate currencies.
Currency ensures a *types.Currency is valid.
CurveType returns an error if the curve is not a valid types.CurveType.
DuplicateRelatedTransaction returns nil if no duplicates are found in the array and returns the first duplicated item found otherwise.
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.
Error ensures a types.Error is valid.
Errors ensures each types.Error in a slice is valid and that there is no error code collision.
EventsBlocksResponse ensures a *types.EventsBlocksResponse is valid.
InitOperationStatus initializes operation status map for a generic rosetta client.
MempoolTransactions returns an error if any types.TransactionIdentifier returns is missing a hash.
NetworkIdentifier ensures a types.NetworkIdentifier has a valid blockchain and network.
NetworkListResponse ensures a types.NetworkListResponse object is valid.
NetworkOptionsResponse ensures a types.NetworkOptionsResponse object is valid.
NetworkStatusResponse ensures any types.NetworkStatusResponse is valid.
NewClientWithFile constructs a new Asserter using a specification file instead of responses.
NewClientWithOptions constructs a new Asserter using the provided arguments instead of using a NetworkStatusResponse and a NetworkOptionsResponse.
NewClientWithResponses constructs a new Asserter from a NetworkStatusResponse and NetworkOptionsResponse.
NewGenericAsserter constructs a new Asserter for generic usage.
NewGenericRosettaClient constructs a new Asserter using the provided arguments and without a Rosetta Spec validation.
NewServer constructs a new Asserter for use in the server package.
OperationIdentifier returns an error if index of the types.Operation is out-of-order or if the NetworkIndex is invalid.
OperationStatuses ensures all items in Options.Allow.OperationStatuses are valid and that there exists at least 1 successful status.
OperationTypes ensures all items in Options.Allow.OperationStatuses are valid and that there are no repeats.
PartialBlockIdentifier ensures a types.PartialBlockIdentifier is well-formatted.
Peer ensures a types.Peer has a valid peer_id.
PublicKey returns an error if the *types.PublicKey is nil, is not valid hex, or has an undefined CurveType.
Signatures returns an error if any *types.Signature is invalid.
SignatureType returns an error if signature is not a valid types.SignatureType.
SigningPayload returns an error if a *types.SigningPayload is nil, has an empty address, has invlaid hex, or has an invalid SignatureType (if populated).
StringArray ensures all strings in an array are non-empty strings and not duplicates.
SubNetworkIdentifier asserts a types.SubNetworkIdentifier is valid (if not nil).
SupportedNetworks returns an error if there is an invalid types.NetworkIdentifier or there is a duplicate.
SyncStatus ensures any types.SyncStatus is valid.
Timestamp returns an error if the timestamp on a block is less than or equal to 0.
TransactionIdentifier returns an error if a types.TransactionIdentifier has an invalid hash.
TransactionIdentifierResponse returns an error if the types.TransactionIdentifier in the response is not valid.
Version ensures the version of the node is returned.

# Constants

No description provided by the author
MaxUnixEpoch is the unix epoch time in milliseconds of 01/01/2040 at 12:00:00 AM.
MinUnixEpoch is the unix epoch time in milliseconds of 01/01/2000 at 12:00:00 AM.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

Account Balance Errors.
Block Errors.
Coin Errors.
Construction Errors.
Block Errors.
Util Errors.
Util Errors.
Util Errors.
Server Errors.
Server Errors.
Server Errors.
Block Errors.
Block Errors.
Network Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
ErrAsserterNotInitialized is returned when some call in the asserter package requires the asserter to be initialized first.
Network Errors.
Network Errors.
Network Errors.
Network Errors.
Network Errors.
Events Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Server Errors.
Server Errors.
Server Errors.
Server Errors.
Server Errors.
Server Errors.
Coin Errors.
Coin Errors.
Coin Errors.
Coin Errors.
Coin Errors.
Coin Errors.
Server Errors.
Server Errors.
Construction Errors.
Server Errors.
Construction Errors.
Server Errors.
Server Errors.
Server Errors.
Construction Errors.
Construction Errors.
Server Errors.
Server Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Server Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Server Errors.
Server Errors.
Construction Errors.
Server Errors.
Server Errors.
Account Balance Errors.
Construction Errors.
Server Errors.
Block Errors.
Error Errors.
Network Errors.
Error Errors.
Network Errors.
Error Errors.
Error Errors.
Error Errors.
Error Errors.
Error Errors.
Server Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Server Errors.
Server Errors.
Events Errors.
Server Errors.
Server Errors.
Server Errors.
Network Errors.
Network Errors.
Network Errors.
Network Errors.
Network Errors.
Network Errors.
Server Errors.
Network Errors.
Search Errors.
Network Errors.
Block Errors.
Network Errors.
Server Errors.
Server Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Server Errors.
Error Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Network Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Block Errors.
Block Errors.
Block Errors.
Block Errors.
Server Errors.
Account Balance Errors.
Account Balance Errors.
Server Errors.
Events Errors.
Events Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Construction Errors.
Util Errors.
Util Errors.
Util Errors.
Network Errors.
Server Errors.
Network Errors.
Network Errors.
Network Errors.
Block Errors.
Block Errors.
Network Errors.
Search Errors.
Block Errors.
Block Errors.
Construction Errors.
Block Errors.
Network Errors.
Network Errors.
Network Errors.
Events Errors.
Network Errors.
Search Errors.
Server Errors.

# Structs

Asserter contains all logic to perform static validation on Rosetta Server responses.
Configuration is the static configuration of an Asserter.
No description provided by the author
No description provided by the author
Validations is used to define stricter validations on the transaction.

# Type aliases

No description provided by the author