Documentation
¶
Overview ¶
* Copyright © 2024 Kaleido, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func ABIBySolDefinition(ctx context.Context, a abi.ABI) (map[string]*abi.Entry, error)
- func ABIInferenceFromJSON(ctx context.Context, inputData RawJSON) (abi.ParameterArray, error)
- func ABIsMustMatch(ctx context.Context, a, b abi.ABI, subMatch ...abi.EntryType) error
- func Int256To65CharDBSafeSortableString(bi *big.Int) string
- func MapEnum[O EnumStringOptions, T any](p Enum[O], mapped map[O]T) (ret T, err error)
- func PadHexBigIntTwosComplement(bi *big.Int, buff []byte) []byte
- func PadHexBigUint(bi *big.Int, buff []byte) []byte
- func RandBytes(count int) []byte
- func RandHex(count int) string
- func ShortID() string
- func StandardABISerializer() *abi.Serializer
- func StrOrEmpty(s *string) string
- func ValidateSafeCharsStartEndAlphaNum(ctx context.Context, val string, maxLen int, fieldName string) error
- type Bytes32
- func ABISolDefinitionHash(ctx context.Context, a abi.ABI, subMatch ...abi.EntryType) (*Bytes32, error)
- func Bytes32Keccak(b []byte) Bytes32
- func Bytes32UUIDFirst16(u uuid.UUID) Bytes32
- func MustParseBytes32(s string) Bytes32
- func NewBytes32FromSlice(bytes []byte) Bytes32
- func ParseBytes32(s string) (Bytes32, error)
- func ParseBytes32Ctx(ctx context.Context, s string) (Bytes32, error)
- func RandBytes32() Bytes32
- func (id Bytes32) Bytes() []byte
- func (id *Bytes32) Equals(id2 *Bytes32) bool
- func (id Bytes32) HexString() string
- func (id Bytes32) HexString0xPrefix() string
- func (id Bytes32) IsZero() bool
- func (id Bytes32) MarshalText() ([]byte, error)
- func (id *Bytes32) Scan(src interface{}) error
- func (id Bytes32) String() string
- func (id Bytes32) UUIDFirst16() (u uuid.UUID)
- func (id *Bytes32) UnmarshalText(text []byte) error
- func (id Bytes32) Value() (driver.Value, error)
- type Enum
- type EnumStringDefault
- type EnumStringOptions
- type EthAddress
- func (a *EthAddress) Address0xHex() *ethtypes.Address0xHex
- func (a *EthAddress) Checksummed() string
- func (a *EthAddress) Equals(b *EthAddress) bool
- func (a EthAddress) HexString() string
- func (a *EthAddress) IsZero() bool
- func (a EthAddress) MarshalJSON() ([]byte, error)
- func (a *EthAddress) Scan(src interface{}) error
- func (a EthAddress) String() string
- func (a *EthAddress) UnmarshalJSON(b []byte) error
- func (a EthAddress) Value() (driver.Value, error)
- type HexBytes
- func (id HexBytes) Equals(id2 HexBytes) bool
- func (id HexBytes) HexString() string
- func (id HexBytes) HexString0xPrefix() string
- func (id HexBytes) MarshalText() ([]byte, error)
- func (id *HexBytes) Scan(src interface{}) error
- func (id HexBytes) String() string
- func (id *HexBytes) UnmarshalText(text []byte) error
- func (id HexBytes) Value() (driver.Value, error)
- type HexInt256
- func (hi *HexInt256) HexString() string
- func (hi *HexInt256) HexString0xPrefix() string
- func (hi *HexInt256) Int() *big.Int
- func (hi *HexInt256) MarshalJSON() ([]byte, error)
- func (hi *HexInt256) NilOrZero() bool
- func (hi *HexInt256) Scan(src interface{}) error
- func (hi *HexInt256) String() string
- func (hi *HexInt256) UnmarshalJSON(b []byte) error
- func (hi *HexInt256) Value() (driver.Value, error)
- type HexUint256
- func (hi *HexUint256) HexString() string
- func (hi *HexUint256) HexString0xPrefix() string
- func (hi *HexUint256) Int() *big.Int
- func (hi *HexUint256) MarshalJSON() ([]byte, error)
- func (hi *HexUint256) NilOrZero() bool
- func (hi *HexUint256) Scan(src interface{}) error
- func (hi *HexUint256) String() string
- func (hi *HexUint256) UnmarshalJSON(b []byte) error
- func (hi *HexUint256) Value() (driver.Value, error)
- type HexUint64
- func (hi HexUint64) HexString() string
- func (hi HexUint64) HexString0xPrefix() string
- func (hi HexUint64) MarshalJSON() ([]byte, error)
- func (id *HexUint64) Scan(src interface{}) error
- func (hi HexUint64) String() string
- func (hi HexUint64) Uint64() uint64
- func (hi *HexUint64) UnmarshalJSON(b []byte) error
- func (hi HexUint64) Value() (driver.Value, error)
- type HexUint64OrString
- type JSONFormatOptions
- type LibraryType
- type OnChainLocation
- type OnChainLocationType
- type OnChainLocations
- type PrivateIdentityLocator
- func (pil PrivateIdentityLocator) FullyQualified(ctx context.Context, defaultNode string) (PrivateIdentityLocator, error)
- func (pil PrivateIdentityLocator) Identity(ctx context.Context) (string, error)
- func (pil PrivateIdentityLocator) Node(ctx context.Context, allowEmptyNode bool) (string, error)
- func (pil PrivateIdentityLocator) String() string
- func (pil PrivateIdentityLocator) Validate(ctx context.Context, defaultNode string, allowEmptyNode bool) (identity string, node string, err error)
- type RawJSON
- func (m RawJSON) Bytes() []byte
- func (m RawJSON) BytesOrNull() []byte
- func (m RawJSON) IsNil() bool
- func (m RawJSON) MarshalJSON() ([]byte, error)
- func (m RawJSON) Pretty() string
- func (m *RawJSON) Scan(src interface{}) error
- func (m RawJSON) String() string
- func (m RawJSON) StringValue() string
- func (m RawJSON) ToMap() (jm map[string]any)
- func (m *RawJSON) UnmarshalJSON(data []byte) error
- func (m RawJSON) Value() driver.Value
- func (m RawJSON) YAML() string
- type Timestamp
- func (ts *Timestamp) Equal(ts2 *Timestamp) bool
- func (ts *Timestamp) MarshalJSON() ([]byte, error)
- func (ts *Timestamp) Scan(src interface{}) error
- func (ts Timestamp) String() string
- func (ts Timestamp) Time() time.Time
- func (ts Timestamp) UnixNano() int64
- func (ts *Timestamp) UnmarshalJSON(b []byte) error
- func (ts Timestamp) Value() (driver.Value, error)
Constants ¶
const DefaultNameMaxLen = 128
const MAX_SAFE_INT64 = 0x7fffffffffffffff
const (
// ShortIDalphabet is designed for easy double-click select
ShortIDalphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
)
Variables ¶
This section is empty.
Functions ¶
func ABIBySolDefinition ¶
func ABIInferenceFromJSON ¶
Takes arbitrary JSON data and attempts to infer an ABI from it. Is not a complete system for all JSON. Current capability set: - Requires top-level JSON to be an object - Does NOT preserve order of properties in a JSON object (Preserving JSON order in Go requires much more complex json.Token based code, or a swap-in library)
- Supports simple types, objects, and arrays of same-typed values - Maps:
- strings -> string
- number -> int256 (as long as input number is whole)
- boolean -> boolean
func ABIsMustMatch ¶
Validates that two ABIs contains exactly the same entires - Includes names of types - Includes indexing and other modifiers - Allows any order of entries
func MapEnum ¶
func MapEnum[O EnumStringOptions, T any](p Enum[O], mapped map[O]T) (ret T, err error)
func PadHexBigIntTwosComplement ¶
PadHexBigIntTwosComplement returns the supplied buffer, with all the bytes to the left of the two's complement formatted string set to 0
func PadHexBigUint ¶
PadHexBigUint returns the supplied buffer, with all the bytes to the left of the integer set to '0'
func StandardABISerializer ¶
func StandardABISerializer() *abi.Serializer
The serializer we should use in all places that go from ABI validated data, back down to JSON that might be: 1) Passed to end-users over a JSON/RPC API 2) Passed to domain plugins over a gRPC API
func StrOrEmpty ¶
Types ¶
type Bytes32 ¶
type Bytes32 [32]byte
Bytes32 is a 32 byte value, with DB storage serialization
func ABISolDefinitionHash ¶
func Bytes32Keccak ¶
func Bytes32UUIDFirst16 ¶
func MustParseBytes32 ¶
func NewBytes32FromSlice ¶
No checking in this function on length
func ParseBytes32 ¶
func ParseBytes32Ctx ¶
Parse a string
func RandBytes32 ¶
func RandBytes32() Bytes32
func (Bytes32) HexString0xPrefix ¶
Get string with 0x prefix - nil is all zeros
func (Bytes32) MarshalText ¶
JSON representation is lower case hex, with 0x prefix
func (Bytes32) String ¶
Natural string representation is HexString0xPrefix() if non-nil, or empty string if ""
func (Bytes32) UUIDFirst16 ¶
Return the first 16 bytes as a UUID
func (*Bytes32) UnmarshalText ¶
Parses with/without 0x in any case
type Enum ¶
type Enum[O EnumStringOptions] string
Enum is a persistence wrapper for an enum with a set of options
func (Enum[O]) MapToString ¶
Case insensitive validation, with default, returning a string value
func (*Enum[O]) Scan ¶
SQL scanner handles strings, bytes, and nil - where nil will be set to the default
type EnumStringDefault ¶
type EnumStringDefault interface {
Default() string
}
type EnumStringOptions ¶
type EthAddress ¶
type EthAddress [20]byte
EthAddress is an SQL serializable version of ethtypes.Address0xHex
func EthAddressBytes ¶
func EthAddressBytes(b []byte) *EthAddress
func MustEthAddress ¶
func MustEthAddress(s string) *EthAddress
func ParseEthAddress ¶
func ParseEthAddress(s string) (*EthAddress, error)
func RandAddress ¶
func RandAddress() *EthAddress
func (*EthAddress) Address0xHex ¶
func (a *EthAddress) Address0xHex() *ethtypes.Address0xHex
func (*EthAddress) Checksummed ¶
func (a *EthAddress) Checksummed() string
func (*EthAddress) Equals ¶
func (a *EthAddress) Equals(b *EthAddress) bool
func (EthAddress) HexString ¶
func (a EthAddress) HexString() string
func (*EthAddress) IsZero ¶
func (a *EthAddress) IsZero() bool
func (EthAddress) MarshalJSON ¶
func (a EthAddress) MarshalJSON() ([]byte, error)
func (*EthAddress) Scan ¶
func (a *EthAddress) Scan(src interface{}) error
Scan implements sql.Scanner
func (EthAddress) String ¶
func (a EthAddress) String() string
func (*EthAddress) UnmarshalJSON ¶
func (a *EthAddress) UnmarshalJSON(b []byte) error
type HexBytes ¶
type HexBytes []byte
HexBytes is byte slice that is formatted in JSON with an 0x prefix, and stored in the DB as hex
func MustParseHexBytes ¶
func ParseHexBytes ¶
Parse a string
func (HexBytes) HexString0xPrefix ¶
Get string with 0x prefix - nil is all zeros
func (HexBytes) MarshalText ¶
JSON representation is lower case hex, with 0x prefix
func (HexBytes) String ¶
Natural string representation is HexString0xPrefix() if non-nil, or empty string if ""
func (*HexBytes) UnmarshalText ¶
Parses with/without 0x in any case
type HexInt256 ¶
HexInt256 is any integer (signed or unsigned) up to 256 bits in size, serialized to the DB using a 65 sortable string (a 0/1 sign character, followed by 32 hex bytes)
func MustParseHexInt256 ¶
func ParseHexInt256 ¶
Parse a string
func (*HexInt256) HexString0xPrefix ¶
Get string with 0x prefix - nil is all zeros
func (*HexInt256) MarshalJSON ¶
JSON representation is lower case hex, with 0x prefix
func (*HexInt256) String ¶
Natural string representation is HexString0xPrefix() if non-nil, or empty string if ""
func (*HexInt256) UnmarshalJSON ¶
Parses with/without 0x in any case
type HexUint256 ¶
HexUint256 is any integer (signed or unsigned) up to 256 bits in size, serialized to the DB using a 65 sortable string (a 0/1 sign character, followed by 32 hex bytes)
func Int64ToInt256 ¶
func Int64ToInt256(v int64) *HexUint256
func MustParseHexUint256 ¶
func MustParseHexUint256(s string) *HexUint256
func ParseHexUint256 ¶
func ParseHexUint256(ctx context.Context, s string) (*HexUint256, error)
Parse a string
func Uint64ToUint256 ¶
func Uint64ToUint256(v uint64) *HexUint256
func (*HexUint256) HexString ¶
func (hi *HexUint256) HexString() string
Get string (without 0x prefix) - nil is all zeros
func (*HexUint256) HexString0xPrefix ¶
func (hi *HexUint256) HexString0xPrefix() string
Get string with 0x prefix - nil is all zeros
func (*HexUint256) Int ¶
func (hi *HexUint256) Int() *big.Int
func (*HexUint256) MarshalJSON ¶
func (hi *HexUint256) MarshalJSON() ([]byte, error)
JSON representation is lower case hex, with 0x prefix
func (*HexUint256) NilOrZero ¶
func (hi *HexUint256) NilOrZero() bool
func (*HexUint256) Scan ¶
func (hi *HexUint256) Scan(src interface{}) error
func (*HexUint256) String ¶
func (hi *HexUint256) String() string
Natural string representation is HexString0xPrefix() if non-nil, or empty string if ""
func (*HexUint256) UnmarshalJSON ¶
func (hi *HexUint256) UnmarshalJSON(b []byte) error
Parses with/without 0x in any case
type HexUint64 ¶
type HexUint64 uint64
HexUint64 is an unsigned integer that is serialized in JSON as hex
func MustParseHexUint64 ¶
func ParseHexUint64 ¶
Parse a string
func (HexUint64) HexString0xPrefix ¶
Get string with 0x prefix - nil is all zeros
func (HexUint64) MarshalJSON ¶
JSON representation is lower case hex, with 0x prefix
func (HexUint64) String ¶
Natural string representation is HexString0xPrefix() if non-nil, or empty string if ""
func (*HexUint64) UnmarshalJSON ¶
Parses with/without 0x in any case
type HexUint64OrString ¶
type HexUint64OrString string
HexUint64OrString is used for things like block numbers, where you can provide a number or a string like "latest".
func (HexUint64OrString) MarshalJSON ¶
func (his HexUint64OrString) MarshalJSON() ([]byte, error)
func (HexUint64OrString) String ¶
func (his HexUint64OrString) String() string
func (*HexUint64OrString) UnmarshalJSON ¶
func (his *HexUint64OrString) UnmarshalJSON(b []byte) error
Parses with/without 0x in any case
type JSONFormatOptions ¶
type JSONFormatOptions string
const DefaultJSONFormatOptions JSONFormatOptions = ""
func (JSONFormatOptions) GetABISerializer ¶
func (jfo JSONFormatOptions) GetABISerializer(ctx context.Context) (serializer *abi.Serializer, err error)
func (JSONFormatOptions) GetABISerializerIgnoreErrors ¶
func (jfo JSONFormatOptions) GetABISerializerIgnoreErrors(ctx context.Context) *abi.Serializer
type LibraryType ¶
type LibraryType string
const ( LibraryTypeJar LibraryType = "jar" )
func (LibraryType) Enum ¶
func (lt LibraryType) Enum() Enum[LibraryType]
func (LibraryType) Options ¶
func (pl LibraryType) Options() []string
type OnChainLocation ¶
type OnChainLocation struct { Type OnChainLocationType TransactionHash Bytes32 BlockNumber int64 TransactionIndex int64 LogIndex int64 // non-zero only for events Source *EthAddress // non-nil only for events }
func (*OnChainLocation) Compare ¶
func (occ *OnChainLocation) Compare(occ2 *OnChainLocation) int
type OnChainLocationType ¶
type OnChainLocationType int
const ( // Note numeric order of these is important for sorting NotOnChain OnChainLocationType = 0 // transactions that did not make it on chain OnChainTransaction OnChainLocationType = 1 // the transaction is the location OnChainEvent OnChainLocationType = 2 // an individual event within the transaction is the location )
type OnChainLocations ¶
type OnChainLocations []*OnChainLocation
func (OnChainLocations) Len ¶
func (l OnChainLocations) Len() int
func (OnChainLocations) Less ¶
func (l OnChainLocations) Less(i, j int) bool
func (OnChainLocations) Swap ¶
func (l OnChainLocations) Swap(i, j int)
type PrivateIdentityLocator ¶
type PrivateIdentityLocator string
The locator for private identities is split into two parts separate by an `@` symbol - A lookup for the identity, which can only be resolved by the node that owns that identity - A lookup for the node, which will be resolved locally to determine which node can resolve the identity
func (PrivateIdentityLocator) FullyQualified ¶
func (pil PrivateIdentityLocator) FullyQualified(ctx context.Context, defaultNode string) (PrivateIdentityLocator, error)
func (PrivateIdentityLocator) Identity ¶
func (pil PrivateIdentityLocator) Identity(ctx context.Context) (string, error)
func (PrivateIdentityLocator) String ¶
func (pil PrivateIdentityLocator) String() string
type RawJSON ¶
type RawJSON []byte
Just like pldtypes.RawJSON, but with ability to SQL serialize to string as well
func JSONString ¶
func (RawJSON) BytesOrNull ¶
func (RawJSON) MarshalJSON ¶
func (RawJSON) StringValue ¶
func (*RawJSON) UnmarshalJSON ¶
type Timestamp ¶
type Timestamp int64
Timestamp stores a Unix timestamp with nanoseconds. Timestamp is serialized to JSON on the API in RFC3339 nanosecond UTC time (noting that JavaScript can parse this format happily into millisecond time with Date.pase()). It is persisted as a nanosecond resolution timestamp in the database. It can be parsed from RFC3339, or unix timestamps (second, millisecond or nanosecond resolution)
func MustParseTimeString ¶
func ParseTimeString ¶
func TimestampFromUnix ¶
func TimestampNow ¶
func TimestampNow() Timestamp