PlutusData

package
v1.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var COST_MODELSV1 = map[serialization.CustomBytes]cbor.Marshaler{{Value: "00"}: PLUTUSV1COSTMODEL}
View Source
var COST_MODELSV2 = map[int]cbor.Marshaler{1: PLUTUSV2COSTMODEL}
View Source
var PLUTUSV1COSTMODEL = CM{}/* 166 elements not displayed */
View Source
var PLUTUSV2COSTMODEL = CostView{}/* 175 elements not displayed */

Functions

func HashDatum

func HashDatum(d cbor.Marshaler) (serialization.DatumHash, error)

*

HashDatum computes the hash of a CBOR marshaler using the Blake2b algorithm.

Params:
	d (cbor.Marshaler): The CBOR marshaler to be hashed

Returns:
	serialization.DatumHash: The hash of the CBOR marshaler.
	error: An error if the hash Datum fails.

func PlutusDataHash

func PlutusDataHash(pd *PlutusData) (serialization.DatumHash, error)

*

	PlutusDataHash computes the hash of a PlutusData structure using the Blake2b algorithm.

 	Params:
	   	pd (*PlutusData): A pointer to the PlutusData structure to be hashed.

	Returns:
  		serialization.DatumHash: The hash of the PlutusData.
		error: An error if the PlutusDataHash fails.

func PlutusScriptHash

func PlutusScriptHash(script ScriptHashable) serialization.ScriptHash

*

PlutusScriptHash computes the script hash of a ScriptHashable object.

Params:
	script (ScriptHashable): The ScriptHashable object to be hashed.

Returns:
	serialization.ScriptHash: The script hash of the ScriptHashable object.

func ToCbor

func ToCbor(x interface{}) (string, error)

*

ToCbor converts the given interface to a hexadecimal-encoded CBOR string.

Params:
	x (interface{}): The input value to be encoded to CBOR to converted
					 to a hexadecimal string.

Returns:
	string: The hexadecimal-encoded CBOR representation of the input value.
	error: An error if the convertion fails.

Types

type CM

type CM map[string]int

func (CM) MarshalCBOR

func (cm CM) MarshalCBOR() ([]byte, error)

*

MarshalCBOR encodes the CM into a CBOR-encoded byte slice, in which
it serializes the map key alphabetically and encodes the respective values.

Returns:
	[]byte: The CBOR-encoded byte slice.
	error: An error if marshaling fails.

type CostModels

type CostModels map[serialization.CustomBytes]CM

type CostView

type CostView map[string]int

func (CostView) MarshalCBOR

func (cm CostView) MarshalCBOR() ([]byte, error)

*

MarshalCBOR encodes the CostView into a CBOR-encoded byte slice, in which
it serializes the map key alphabetically and encodes the respective values.

Returns:
	[]byte: The CBOR-encoded byte slice.
	error: An error if marshaling fails.

type Datum

type Datum struct {
	PlutusDataType PlutusType
	TagNr          uint64
	Value          any
}

func (*Datum) Clone

func (pd *Datum) Clone() Datum

*

Clone creates a deep copy of the Datum>

Returns:
	Datum: A deep copy of the Datum

func (Datum) MarshalCBOR

func (pd Datum) MarshalCBOR() ([]uint8, error)

*

	MarshalCBOR encodes the Datum into a CBOR-encoded byte slice,
	it applies a CBOR tag, if TagNr is not 0, otherwise it marshals the Value

	Returns:
   		[]uint8: The CBOR-encoded byte slice.
   		error: An error if marshaling fails.

func (*Datum) ToPlutusData

func (pd *Datum) ToPlutusData() PlutusData

*

ToPlutusData converts a datum to PlutusData, encoding
the Datum into CBOR format and then decodes it into a
PlutusData.

Returns:
	PlutusData: The converted PlutusData.

func (*Datum) UnmarshalCBOR

func (pd *Datum) UnmarshalCBOR(value []uint8) error

*

	UnmarshalCBOR decodes a CBOR-encoded byte slice into a Datum.
	It handles different Plutus data types and applies appropriate decoding logic.

	Returns:
   		error: An error if unmarshaling fails.

type DatumOption added in v1.0.5

type DatumOption struct {
	DatumType DatumType
	Hash      []byte
	Inline    *PlutusData
	// contains filtered or unexported fields
}

func DatumOptionHash added in v1.0.5

func DatumOptionHash(hash []byte) DatumOption

func DatumOptionInline added in v1.0.5

func DatumOptionInline(pd *PlutusData) DatumOption

func (DatumOption) MarshalCBOR added in v1.0.5

func (d DatumOption) MarshalCBOR() ([]byte, error)

func (*DatumOption) UnmarshalCBOR added in v1.0.5

func (d *DatumOption) UnmarshalCBOR(b []byte) error

type DatumType added in v1.0.5

type DatumType byte
const (
	DatumTypeHash   DatumType = 0
	DatumTypeInline DatumType = 1
)

type PlutusData

type PlutusData struct {
	PlutusDataType PlutusType
	TagNr          uint64
	Value          any
}

func (*PlutusData) Clone

func (pd *PlutusData) Clone() PlutusData

*

Clone creates a deep copy of a PlutusData object.

Returns:
	PlutusData: A cloned PlutusData object.

func (*PlutusData) Equal added in v1.0.3

func (pd *PlutusData) Equal(other PlutusData) bool

*

Equal check if two PlutusData values are equal
using their CBOR representations.

Params:
	other (PlutusData): The other PlutusData to compare to.

Returns:
	bool: True if the PlutusData are equal, false otherwise.

func (*PlutusData) MarshalCBOR

func (pd *PlutusData) MarshalCBOR() ([]uint8, error)

*

MarshalCBOR encodes the PlutusData into a CBOR byte slice.

Returns:
	[]uint8: The CBOR-encoded byte slice.
	error: An error, if any, during ecoding.

func (*PlutusData) ToDatum

func (pd *PlutusData) ToDatum() Datum

*

ToDatum converts a PlutusData to a Datum, in which
it encodes the PlutusData into CBOR format and later
into a Datum.

Returns:
	Datum: The converted Datum.

func (*PlutusData) UnmarshalCBOR

func (pd *PlutusData) UnmarshalCBOR(value []uint8) error

*

	UnmarshalCBOR unmarshals CBOR-encoded data into a PlutusData object.

	Params:
   		value ([]uint8): The CBOR-encoded data to unmarshal.

 	Returns:
   		error: An error, if any, during unmarshaling.

func (*PlutusData) UnmarshalJSON added in v1.0.3

func (pd *PlutusData) UnmarshalJSON(value []byte) error

*

	UnmarshalJSON unmarshals JSON-encoded PlutusData into a PlutusData object.

	Params:
   		value ([]byte): The JSON-encoded data to unmarshal.

 	Returns:
   		error: An error, if any, during unmarshaling.

type PlutusDefArray added in v1.0.3

type PlutusDefArray []PlutusData

func (PlutusDefArray) Len added in v1.0.3

func (pia PlutusDefArray) Len() int

*

Len returns the length of the PlutusDefArray.

Returns:
	int: The length of the PlutusDefArray.

type PlutusIndefArray

type PlutusIndefArray []PlutusData

func (*PlutusIndefArray) Clone

func (pia *PlutusIndefArray) Clone() PlutusIndefArray

*

Clone creates a deep copy of the PlutusIndefArray.

Returns:
	PlutusIndefArray: A deep copy of the PlutusIndefArray.

func (PlutusIndefArray) Len added in v1.0.3

func (pia PlutusIndefArray) Len() int

*

Len returns the length of the PlutusIndefArray.

Returns:
	int: The length of the PlutusIndefArray.

func (PlutusIndefArray) MarshalCBOR

func (pia PlutusIndefArray) MarshalCBOR() ([]uint8, error)

*

	MarshalCBOR encodes the PlutusIndefArray into a CBOR-encoded byte
	slice, in which it serializes the elements in indefinite-length array format.

	Returns:
   		[]uint8: The CBOR-encoded byte slice.
   		error: An error if marshaling fails.

type PlutusList added in v1.0.3

type PlutusList interface {
	Len() int
}

type PlutusType

type PlutusType int
const (
	PlutusArray PlutusType = iota
	PlutusMap
	PlutusInt
	PlutusBytes
	PlutusShortArray
)

type PlutusV1Script

type PlutusV1Script []byte

func (PlutusV1Script) Hash

*

 	Hash computes the script hash for a PlutusV1Script.

 	Returns:
   		serialization.ScriptHash: The script hash of the PlutusV1Script.
		error: An error if the hashing fails.

func (*PlutusV1Script) ToAddress added in v1.0.3

func (ps *PlutusV1Script) ToAddress(stakingCredential []byte) Address.Address

*

	ToAddress converts a PlutusV1Script to an Address with an optional staking credential.

 	Params:
   		stakingCredential ([]byte): The staking credential to include in the address.

 	Returns:
   		Address.Address: The generated address.

type PlutusV2Script

type PlutusV2Script []byte

func (PlutusV2Script) Hash

*

 	Hash computes the script hash for a PlutusV2Script.

 	Returns:
   		serialization.ScriptHash: The script hash of the PlutusV2Script.
		error: An error if the Hashing fails.

func (*PlutusV2Script) ToAddress added in v1.0.3

func (ps *PlutusV2Script) ToAddress(stakingCredential []byte) Address.Address

*

	ToAddress converts a PlutusV2Script to an Address with an optional staking credential.

 	Params:
   		stakingCredential ([]byte): The staking credential to include in the address.

 	Returns:
   		Address.Address: The generated address.

type RawPlutusData

type RawPlutusData struct {
}

type ScriptHashable

type ScriptHashable interface {
	Hash() (serialization.ScriptHash, error)
}

type ScriptRef

type ScriptRef struct {
	Script _Script
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL