types

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0, MIT Imports: 3 Imported by: 4

Documentation

Overview

Package types defines common types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(a *big.Int, b *big.Int) bool

Equal returns true if a == b or if both of a and b are nil, and false otherwise.

func Gt

func Gt(a *big.Int, b *big.Int) bool

Gt returns true if a > b, false otherwise

func IsZero

func IsZero(a *big.Int) bool

IsZero returns true if a is zero, false otherwise.

func Lt

func Lt(a *big.Int, b *big.Int) bool

Lt returns true if a < b, false otherwise

func Max

func Max(a *big.Int, b *big.Int) *big.Int

Max returns a if a > b, b otherwise.

func Min

func Min(a *big.Int, b *big.Int) *big.Int

Max returns a if a > b, b otherwise.

Types

type Address

type Address = common.Address

An ethereum address (20 bytes)

type Bytes

type Bytes []byte

An arbitrary length byte slice

type Bytes32

type Bytes32 = common.Hash

An ethereum hash (32 bytes)

type ConstError

type ConstError string

ConstError is a const-friendly error type.

func (ConstError) Error

func (c ConstError) Error() string

type Destination

type Destination Bytes32

Destination represents a payable address in go-nitro. In a state channel network, payable address are either:

  • Internal: a 32-byte nitro channel ID, or
  • External: a blockchain account or contract address, left-padded with 0s

func AddressToDestination

func AddressToDestination(a Address) Destination

AddressToDestinaion left-pads the blockchain address with zeros.

func (Destination) Bytes

func (d Destination) Bytes() []byte

func (Destination) IsExternal

func (d Destination) IsExternal() bool

IsExternal returns true if the destination is a blockchain address, and false if it is a state channel ID.

func (Destination) IsZero

func (d Destination) IsZero() bool

IsZero returns true if the destination is all zeros, and false otherwise.

func (Destination) MarshalText

func (d Destination) MarshalText() (text []byte, err error)

MarshalText encodes the receiver into UTF-8-encoded text and returns the result.

This makes Destination an encoding.TextMarshaler, meaning it can be safely used as the key in a map which will be encoded into json.

func (Destination) String

func (d Destination) String() string

func (Destination) ToAddress

func (d Destination) ToAddress() (Address, error)

ToAddress returns a types.Address encoded external destination, or an error if destination is not an external address

func (*Destination) UnmarshalText

func (d *Destination) UnmarshalText(text []byte) error

UnmarshalText unmarshals the supplied text (assumed to be a valid marshaling) into the receiver.

This makes Destination an encoding.TextUnmarshaler.

type Funds

type Funds map[common.Address]*big.Int

A {tokenAddress: amount} map. Address 0 represents a chain's native token (ETH, FIL, etc)

func Sum

func Sum(a ...Funds) Funds

Sum returns a new Funds object with all of the asset keys from the supplied Funds objects, each having an amount summed across that asset's amount in each input object.

e.g. {[0x0a,0x01][0x0b,0x01]} + {[0x0a,0x02]} = {[0x0a,0x03][0x0b,0x01]}

func (Funds) Add

func (h Funds) Add(a ...Funds) Funds

Add returns the sum of the receiver and the input Funds objects

func (Funds) Clone

func (f Funds) Clone() Funds

Clone returns a deep copy of the receiver.

func (Funds) Equal

func (f Funds) Equal(g Funds) bool

Equal returns true if receiver and input g are identical in monetary value, and false otherwise.

Note that a zero-balance equals a non-balance: {[0x0a,0x00],[0x0b,0x01]} == {[0x0b,0x01]}

func (Funds) IsNonZero

func (h Funds) IsNonZero() bool

IsNonZero returns true if the Holdings structure has any non-zero asset

func (Funds) String

func (h Funds) String() string

String returns a bracket-separaged list of assets: {[0x0a,0x01][0x0b,0x01]}

type Uint256

type Uint256 = big.Int

We use a big.Int to represent Solidity's uint256

Jump to

Keyboard shortcuts

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