Documentation
¶
Index ¶
- Constants
- Variables
- func ExponentToPrefix(exponent uint32) (string, error)
- func FormatBatchDenom(projectID string, batchSeqNo uint64, startDate, endDate *time.Time) (string, error)
- func FormatClassID(creditTypeAbbreviation string, classSeqNo uint64) string
- func FormatProjectID(classID string, projectSeqNo uint64) string
- func GetClassIDFromBatchDenom(denom string) string
- func GetClassIDFromProjectID(projectID string) string
- func GetCreditTypeAbbrevFromClassID(classID string) string
- func GetProjectIDFromBatchDenom(denom string) string
- func ValidateBatchDenom(denom string) error
- func ValidateClassID(classID string) error
- func ValidateCreditTypeAbbreviation(abbr string) error
- func ValidateJurisdiction(jurisdiction string) error
- func ValidateProjectID(projectID string) error
Constants ¶
const ( // MaxMetadataLength defines the max length of the metadata bytes field // for the credit-class & credit-batch. MaxMetadataLength = 256 // MaxNoteLength defines the max length for note fields. MaxNoteLength = 512 )
Variables ¶
var ( RegexCreditTypeAbbrev = `[A-Z]{1,3}` //nolint:gosec RegexClassID = fmt.Sprintf(`%s[0-9]{2,}`, RegexCreditTypeAbbrev) RegexProjectID = fmt.Sprintf(`%s-[0-9]{3,}`, RegexClassID) RegexBatchDenom = fmt.Sprintf(`%s-[0-9]{8}-[0-9]{8}-[0-9]{3,}`, RegexProjectID) RegexJurisdiction = `([A-Z]{2})(?:-([A-Z0-9]{1,3})(?: ([a-zA-Z0-9 \-]{1,64}))?)?` )
Functions ¶
func ExponentToPrefix ¶
ExponentToPrefix returns a denom prefix for a given exponent. Returns error if the exponent is not supported.
func FormatBatchDenom ¶
func FormatBatchDenom(projectID string, batchSeqNo uint64, startDate, endDate *time.Time) (string, error)
FormatBatchDenom formats the unique denomination for a credit batch. This format may evolve over time, but will maintain backwards compatibility.
The current version has the format: <project-id>-<start_date>-<end_date>-<batch_sequence>
<project-id> is the unique identifier of the project (see FormatProjectID) <start-date> is the start date of the credit batch with the format YYYYMMDD <end-date> is the end date of the credit batch with the format YYYYMMDD <batch-sequence> is the sequence number of the credit batch, padded to at least three digits
e.g. C01-001-20190101-20200101-001
func FormatClassID ¶
FormatClassID formats the unique identifier for a new credit class, based on the credit type abbreviation and the credit class sequence number. This format may evolve over time, but will maintain backwards compatibility.
The current version has the format: <credit-type-abbrev><class-sequence>
<credit-type-abbrev> is the unique identifier of the credit type <class-sequence> is the sequence number of the credit class, padded to at least three digits
e.g. C01
func FormatProjectID ¶
FormatProjectID formats the unique identifier for a new project, based on the credit class id and project sequence number. This format may evolve over time, but will maintain backwards compatibility.
The current version has the format: <class-id>-<project-sequence>
<class-id> is the unique identifier of the credit class (see FormatClassID) <project-sequence> is the sequence number of the project, padded to at least three digits
e.g. C01-001
func GetClassIDFromBatchDenom ¶
GetClassIDFromBatchDenom returns the credit class ID in a batch denom.
func GetClassIDFromProjectID ¶
GetClassIDFromProjectID returns the credit class ID in a project ID.
func GetCreditTypeAbbrevFromClassID ¶
GetCreditTypeAbbrevFromClassID returns the credit type abbreviation in a credit class id
func GetProjectIDFromBatchDenom ¶
GetProjectIDFromBatchDenom returns the credit project ID in a batch denom.
func ValidateBatchDenom ¶
ValidateBatchDenom validates a batch denomination conforms to the format described in FormatBatchDenom. The return is nil if the denom is valid.
func ValidateClassID ¶
ValidateClassID validates a class ID conforms to the format described in FormatClassID. The return is nil if the ID is valid.
func ValidateCreditTypeAbbreviation ¶
ValidateCreditTypeAbbreviation validates a credit type abbreviation, ensuring it is only 1-3 uppercase letters. The return is nil if the abbreviation is valid.
func ValidateJurisdiction ¶
ValidateJurisdiction checks that the country and region conform to ISO 3166 and the postal code is valid. This is a simple regex check and doesn't check that the country or subdivision codes actually exist. This is because the codes could change at short notice and we don't want to hardfork to keep up-to-date with that information. The return is nil if the jurisdiction is valid.
func ValidateProjectID ¶
ValidateProjectID validates a project ID conforms to the format described in FormatProjectID. The return is nil if the ID is valid.
Types ¶
This section is empty.