Documentation ¶
Index ¶
- func AccountBalance(block *rosetta.BlockIdentifier, balances []*rosetta.Balance) error
- func AccountIdentifier(account *rosetta.AccountIdentifier) error
- func Amount(amount *rosetta.Amount) error
- func BlockIdentifier(blockIdentifier *rosetta.BlockIdentifier) error
- func Error(err *rosetta.Error) error
- func Errors(rosettaErrors []*rosetta.Error) error
- func MempoolTransactions(transactions []*rosetta.TransactionIdentifier) error
- func NetworkIdentifier(network *rosetta.NetworkIdentifier) error
- func NetworkInformation(networkInformation *rosetta.NetworkInformation) error
- func NetworkOptions(options *rosetta.Options) error
- func NetworkStatus(networkStatus *rosetta.NetworkStatus) error
- func NetworkStatusResponse(response *rosetta.NetworkStatusResponse) error
- func OperationIdentifier(identifier *rosetta.OperationIdentifier, index int64) error
- func OperationStatuses(statuses []*rosetta.OperationStatus) error
- func Peer(peer *rosetta.Peer) error
- func StringArray(arrName string, arr []string) error
- func SubNetworkIdentifier(subNetworkIdentifier *rosetta.SubNetworkIdentifier) error
- func Timestamp(timestamp int64) error
- func TransactionConstruction(response *rosetta.TransactionConstructionResponse) error
- func TransactionIdentifier(transactionIdentifier *rosetta.TransactionIdentifier) error
- func Version(version *rosetta.Version) error
- type Asserter
- func (a *Asserter) Block(ctx context.Context, block *rosetta.Block) error
- func (a *Asserter) Operation(operation *rosetta.Operation, index int64) error
- func (a *Asserter) OperationSuccessful(operation *rosetta.Operation) (bool, error)
- func (a *Asserter) Transaction(transaction *rosetta.Transaction) error
- func (a *Asserter) TransactionSubmit(response *rosetta.TransactionSubmitResponse) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccountBalance ¶
func AccountBalance( block *rosetta.BlockIdentifier, balances []*rosetta.Balance, ) error
AccountBalance returns an error if the provided rosetta.BlockIdentifier is invalid, if the same rosetta.AccountIdentifier appears in multiple rosetta.Balance structs (should be consolidated), or if a rosetta.Balance is considered invalid.
func AccountIdentifier ¶
func AccountIdentifier(account *rosetta.AccountIdentifier) error
AccountIdentifier returns an error if a rosetta.AccountIdentifier is missing an address or a provided SubAccount is missing an identifier.
func Amount ¶
Amount ensures a rosetta.Amount has an integer value, specified precision, and symbol.
func BlockIdentifier ¶
func BlockIdentifier(blockIdentifier *rosetta.BlockIdentifier) error
BlockIdentifier ensures a rosetta.BlockIdentifier is well-formatted.
func Errors ¶ added in v0.0.4
Errors ensures each rosetta.Error in a slice is valid and that there is no error code collision.
func MempoolTransactions ¶
func MempoolTransactions( transactions []*rosetta.TransactionIdentifier, ) error
MempoolTransactions returns an error if any rosetta.TransactionIdentifier returns is missing a hash. The correctness of each populated MempoolTransaction is asserted by Transaction.
func NetworkIdentifier ¶
func NetworkIdentifier(network *rosetta.NetworkIdentifier) error
NetworkIdentifier ensures a rosetta.NetworkIdentifier has a valid blockchain and network.
func NetworkInformation ¶
func NetworkInformation(networkInformation *rosetta.NetworkInformation) error
NetworkInformation ensures any rosetta.NetworkInformation included in rosetta.NetworkStatus or rosetta.SubNetworkStatus is valid.
func NetworkOptions ¶
NetworkOptions ensures a rosetta.Options object is valid.
func NetworkStatus ¶
func NetworkStatus(networkStatus *rosetta.NetworkStatus) error
NetworkStatus ensures a rosetta.NetworkStatus object is valid.
func NetworkStatusResponse ¶
func NetworkStatusResponse(response *rosetta.NetworkStatusResponse) error
NetworkStatusResponse orchestrates assertions for all components of a rosetta.NetworkStatus.
func OperationIdentifier ¶
func OperationIdentifier( identifier *rosetta.OperationIdentifier, index int64, ) error
OperationIdentifier returns an error if index of the rosetta.Operation is out-of-order or if the NetworkIndex is invalid.
func OperationStatuses ¶
func OperationStatuses(statuses []*rosetta.OperationStatus) error
OperationStatuses ensures all items in Options.OperationStatuses are valid and that there exists at least 1 successful status.
func StringArray ¶
StringArray ensures all strings in an array are non-empty strings.
func SubNetworkIdentifier ¶
func SubNetworkIdentifier(subNetworkIdentifier *rosetta.SubNetworkIdentifier) error
SubNetworkIdentifier asserts a rosetta.SubNetworkIdentifer is valid (if not nil).
func TransactionConstruction ¶
func TransactionConstruction( response *rosetta.TransactionConstructionResponse, ) error
TransactionConstruction returns an error if the NetworkFee is not a valid rosetta.Amount.
func TransactionIdentifier ¶
func TransactionIdentifier( transactionIdentifier *rosetta.TransactionIdentifier, ) error
TransactionIdentifier returns an error if a rosetta.TransactionIdentifier has an invalid hash.
Types ¶
type Asserter ¶
type Asserter struct {
// contains filtered or unexported fields
}
Asserter contains all logic to perform static validation on Rosetta Server responses.
func NewOptions ¶ added in v0.0.4
func NewOptions( ctx context.Context, genesisBlockIdentifier *rosetta.BlockIdentifier, operationTypes []string, operationStatuses []*rosetta.OperationStatus, errors []*rosetta.Error, ) *Asserter
NewOptions constructs a new Asserter using the provided arguments instead of using a rosetta.NetworkStatusResponse.
func (*Asserter) Operation ¶
Operation ensures a rosetta.Operation has a valid type, status, and amount.
func (*Asserter) OperationSuccessful ¶
OperationSuccessful returns a boolean indicating if a rosetta.Operation is successful and should be applied in a transaction. This should only be called AFTER an operation has been validated.
func (*Asserter) Transaction ¶
func (a *Asserter) Transaction( transaction *rosetta.Transaction, ) error
Transaction returns an error if the rosetta.TransactionIdentifier is invalid, if any rosetta.Operation within the rosetta.Transaction is invalid, or if any operation index is reused within a transaction.
func (*Asserter) TransactionSubmit ¶
func (a *Asserter) TransactionSubmit( response *rosetta.TransactionSubmitResponse, ) error
TransactionSubmit returns an error if the rosetta.TransactionIdentifier in the response is not valid or if the Submission.Status is not contained within the provided validStatuses slice.