Value

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlonzoValue added in v1.0.3

type AlonzoValue struct {
	Am        Amount.AlonzoAmount
	Coin      int64
	HasAssets bool
}

func (AlonzoValue) Clone added in v1.0.3

func (alVal AlonzoValue) Clone() AlonzoValue

*

Clone creates a copy of the AlonzoValue, including its assets.

Returns:
	AlonzoValue: A copy of the AlonzoValue.

func (*AlonzoValue) MarshalCBOR added in v1.0.3

func (alVal *AlonzoValue) MarshalCBOR() ([]byte, error)

*

MarshalCBOR serializes the AlonzoValue into an CBOr-encoded data.

Returns:
	[]byte: The CBOR-encoded data.
	error: An error if deserialization fails.

func (AlonzoValue) ToValue added in v1.0.3

func (alVal AlonzoValue) ToValue() Value

*

ToValue converts an AlonzoValue to a Value object, preserving its attributes.

Returns:
	Value: A Value object converted from an AlonzoValue.

func (*AlonzoValue) UnmarshalCBOR added in v1.0.3

func (val *AlonzoValue) UnmarshalCBOR(value []byte) error

*

UnmarshalCBOR deserializes CBOr-encoded data into an AlonzoValue.

Params:
	value ([]byte): The CBOR-encoded data to be deserialized.

Returns:
	error: An error if deserialization fails.

type Value

type Value struct {
	Am        Amount.Amount
	Coin      int64
	HasAssets bool
}

func PureLovelaceValue

func PureLovelaceValue(coin int64) Value

*

 	PureLovelaceValue creates a Value with only a specified amount
	of Lovelace (coin) and no assets.

	Params:
		coin (int64): The amount of Lovelace (coin) to set in the Value.

	Returns:
		Value: The Value with the specified amount of Lovelace and no assets.

func SimpleValue

func SimpleValue(coin int64, assets MultiAsset.MultiAsset[int64]) Value

*

SimpleValue creates a Value object with a specified coin value and a MultiAssets.

Params:
	coin (int64): The coin value.
	assets (MultiAsset.MultiAsset[int64]): the assets.

Returns:
	Value: A Value object.

func (Value) Add

func (val Value) Add(other Value) Value

*

Add function adds another Value to the current Value.

Params:
	other (Value): The Value to add to the current Value.

Returns:
	Value: The resulting Value after the addition.

func (*Value) AddAssets

func (val *Value) AddAssets(other MultiAsset.MultiAsset[int64])

*

AddAssets adds MultiAsset assets to a Value.

Params:
	other (MultiAsset.MultiAsset[int64]): the MultiAssets assets to be added.

func (*Value) AddLovelace

func (val *Value) AddLovelace(amount int64)

*

AddLovelace adds a specified amount of Lovelace (coin) from the Value.
In case that there aren't any assets, then it adds to the Coin field,
otherwise to the AlonzoAmount's Coin field.

Params:
	amount (int64): The amount of Lovelace (coin) to add.

func (Value) Clone

func (val Value) Clone() Value

*

Clone creates a copy of the Value, including its assets.

Returns:
	Value: A copy of the Value.

func (Value) Equal

func (val Value) Equal(other Value) bool

*

Equal checks if the current Value is equal to another Value.

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

Returns:
	bool: True if the current value is equal to the other Value, false otherwise.

func (Value) GetAssets

func (val Value) GetAssets() MultiAsset.MultiAsset[int64]

*

GetAssets returns the MultiAsset assets in the Value.

Returns:
	MultiAsset.MultiAsset[int64]: The MultiAsset assets.

func (Value) GetCoin

func (val Value) GetCoin() int64

*

GetCoin returns the amount of Lovelace (coin) in the Value.

Returns:
	int64: The amount of Lovelace (coin).

func (Value) Greater

func (val Value) Greater(other Value) bool

*

Greater checks if the current Value is greater than another Value.

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

Returns:
	bool: True if the current value is greater than the other Value, false otherwise.

func (Value) GreaterOrEqual

func (val Value) GreaterOrEqual(other Value) bool

*

GreaterOrEqual checks if the current Value is greater than or equal to another Value.

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

Returns:
	bool: True if the current value is greater than or equal to the other Value, false otherwise.

func (Value) Less

func (val Value) Less(other Value) bool

*

Less checks if the current Value is less than another Value.

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

Returns:
	bool: True if the current value is less than the other Value, false otherwise.

func (Value) LessOrEqual

func (val Value) LessOrEqual(other Value) bool

*

LessOrEqual checks if the current Value is less than or equal to another Value.

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

Returns:
	bool: True if the current value is less than or equal to the other Value, false otherwise.

func (*Value) MarshalCBOR

func (val *Value) MarshalCBOR() ([]byte, error)

*

MarshalCBOR marshals the Value into a CBOR-encoded byte slice.
If the Value has assets, then it encodes the AlonzoAmount using CBOR,
otherwise it encodes the Coin field directly.

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

func (Value) RemoveZeroAssets

func (val Value) RemoveZeroAssets() Value

*

RemoveZeroAssets removes assets with zero values from a Value.

Returns:
	Value: A Value without zero assets.

func (*Value) SetLovelace

func (val *Value) SetLovelace(amount int64)

*

SetLovelace sets a specified amount of Lovelace (coin) in the Value.
In case that there aren't any assets, then it sets the Coin field,
otherwise it sets the AlonzoAmount's Coin field.

Params:
	amount (int64): The amount of Lovelace (coin) to set.

func (*Value) SetMultiAsset

func (val *Value) SetMultiAsset(amount MultiAsset.MultiAsset[int64])

*

SetMultiAsset sets the MultiAsset in the Value.

Params:
	amount (MultiAsset.MultiAsset[int64]): The MultiAsset assets to set.

func (Value) String

func (val Value) String() string

*

String reutnrs a string representation of teh Value.

Returns:
	string: The string representation of the Value.

func (Value) Sub

func (val Value) Sub(other Value) Value

*

Sub function subtracts another Value to the current Value.

Params:
	other (Value): The Value to subtract to the current Value.

Returns:
	Value: The resulting Value after the subtraction.

func (*Value) SubLovelace

func (val *Value) SubLovelace(amount int64)

*

SubLovelace subtracts a specified amount of Lovelace (coin) from the Value.
In case that there aren't any assets, then it subtracts from the Coin field,
otherwise from the AlonzoAmount's Coin field.

Params:
	amount (int64): The amount of Lovelace (coin) to subtract.

func (Value) ToAlonzoValue added in v1.0.3

func (val Value) ToAlonzoValue() AlonzoValue

*

ToAlonzoValue converts a Value object to an AlonzoValue, preserving its attributes.

Returns:
	AlonzoValue: An AlonzoValue converted from a Value object.

func (*Value) UnmarshalCBOR

func (val *Value) UnmarshalCBOR(value []byte) error

*

	UnmarshalCBOR unmarshals a CBOR-encoded byte slice into the Value,
	which decoed either a uint64 inot the Coin field or a CBOR-encoded Amount
	into the AlonzoAmount field.

	Params:
    	value ([]byte): The CBOR-encoded byte slice to unmarshal.

  	Returns:
    	error: An error if unmarshaling fails.

Jump to

Keyboard shortcuts

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