rum

package module
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 19 Imported by: 1

README

rum

A golang library for Cardano development, compatible with Mesh and Whisky types.

Installation

go get github.com/sidan-lab/rum@latest

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllNetworks = []Network{Testnet, Preview, Preprod, Mainnet}
View Source
var NetworkMap = map[string]string{
	"testnet": blockfrost.CardanoTestNet,
	"preview": blockfrost.CardanoPreview,
	"preprod": blockfrost.CardanoPreProd,
	"mainnet": blockfrost.CardanoMainNet,
}

Functions

func AddQuantities

func AddQuantities(quantity1 string, quantity2 string) string

func DecryptWithCipher added in v0.2.2

func DecryptWithCipher(encryptedDataJSON string, password string) (string, error)

func EncryptWithCipher added in v0.2.2

func EncryptWithCipher(data, key string, initializationVectorSize int) (string, error)

EncryptWithCipher encrypts data using PBKDF2 key derivation and AES-GCM

func GetServerURL

func GetServerURL(projectID string) string

func IsNetwork

func IsNetwork(value string) bool

Types

type AccountInfo

type AccountInfo struct {
	Active      bool
	PoolId      *string
	Balance     string
	Rewards     string
	Withdrawals string
}

type Asset

type Asset struct {
	Unit     string `json:"unit" binding:"required"`
	Quantity string `json:"quantity" binding:"required"`
}

func BfAddressAmountsToAssets added in v0.3.2

func BfAddressAmountsToAssets(bfAmounts []blockfrost.AddressAmount) []Asset

func BfToAsset

func BfToAsset(bfAsset blockfrost.TxAmount) Asset

func BfToAssets

func BfToAssets(bfAssets []blockfrost.TxAmount) []Asset

func MsToAsset

func MsToAsset(msAsset msModel.Asset) Asset

func MsToAssets

func MsToAssets(msAssets []msModel.Asset) []Asset

type AssetMetadata

type AssetMetadata = map[string]interface{}

type Assets

type Assets []Asset

func (*Assets) GetLovelace

func (a *Assets) GetLovelace() uint64

func (*Assets) MergeAssets

func (a *Assets) MergeAssets(assets []Asset) *[]Asset

func (*Assets) PopAssetByUnit

func (a *Assets) PopAssetByUnit(unit string) *Asset

type BlockInfo

type BlockInfo struct {
	Time                   int
	Hash                   string
	Slot                   string
	Epoch                  int
	EpochSlot              string
	SlotLeader             string
	Size                   int
	TxCount                int
	Output                 string
	Fees                   string
	PreviousBlock          string
	NextBlock              string
	Confirmations          int
	OperationalCertificate string
	VRFKey                 string
}

type BlockfrostProvider

type BlockfrostProvider struct {
	// contains filtered or unexported fields
}

func NewBlockfrostProvider

func NewBlockfrostProvider(projectID string) *BlockfrostProvider

func (*BlockfrostProvider) FetchAddressUTxOs added in v0.3.2

func (bf *BlockfrostProvider) FetchAddressUTxOs(address string, asset *string) ([]UTxO, error)

func (*BlockfrostProvider) FetchTxInfo

func (bf *BlockfrostProvider) FetchTxInfo(hash string) (TransactionInfo, error)

func (*BlockfrostProvider) FetchUTxOs

func (bf *BlockfrostProvider) FetchUTxOs(hash string, index *int) ([]UTxO, error)

func (*BlockfrostProvider) SubmitTx

func (bf *BlockfrostProvider) SubmitTx(txCbor string) (string, error)

type CipherData added in v0.2.2

type CipherData struct {
	IV         string `json:"iv"`
	Ciphertext string `json:"ciphertext"`
}

CipherData represents the structure of encrypted data

type HttpOgmiosProvider added in v0.3.4

type HttpOgmiosProvider struct {
	// contains filtered or unexported fields
}

func (*HttpOgmiosProvider) SubmitTx added in v0.3.4

func (o *HttpOgmiosProvider) SubmitTx(txCbor string) (string, error)

type IFetcher

type IFetcher interface {
	// FetchAccountInfo(address string) (AccountInfo, error)
	FetchAddressUTxOs(address string, asset *string) ([]UTxO, error)
	// FetchAssetAddresses(asset string) ([]struct {
	// 	Address  string
	// 	Quantity string
	// }, error)
	// FetchAssetMetadata(asset string) (AssetMetadata, error)
	// FetchBlockInfo(hash string) (BlockInfo, error)
	// FetchCollectionAssets(policyId string, cursor *interface{}) (struct {
	// 	Assets Assets
	// 	Next   *interface{}
	// }, error)
	// FetchHandle(handle string) (map[string]interface{}, error)
	// FetchHandleAddress(handle string) (string, error)
	// FetchProtocolParameters(epoch int) (Protocol, error)
	FetchTxInfo(hash string) (TransactionInfo, error)
	FetchUTxOs(hash string, index *int) ([]UTxO, error)
}

TODO: interface add context params and respect context instead of using context.TODO()

func NewKupoProvider added in v0.3.4

func NewKupoProvider(baseUrl string, httpClient *http.Client) IFetcher

type IProvider

type IProvider interface {
	IFetcher
	ISubmitter
}

type ISubmitter

type ISubmitter interface {
	SubmitTx(txCbor string) (string, error)
}

func NewHttpOgmiosProvider added in v0.3.4

func NewHttpOgmiosProvider(baseUrl string) ISubmitter

func NewOgmiosProvider added in v0.3.4

func NewOgmiosProvider(baseUrl string, logger ogmigo.Logger) ISubmitter

type Input

type Input struct {
	OutputIndex int    `json:"output_index" binding:"required"`
	TxHash      string `json:"tx_hash" binding:"required"`
}

type KupoProvider added in v0.3.4

type KupoProvider struct {
	// contains filtered or unexported fields
}

func (*KupoProvider) FetchAddressUTxOs added in v0.3.4

func (kp *KupoProvider) FetchAddressUTxOs(address string, asset *string) ([]UTxO, error)

func (*KupoProvider) FetchTxInfo added in v0.3.4

func (kp *KupoProvider) FetchTxInfo(hash string) (TransactionInfo, error)

func (*KupoProvider) FetchUTxOs added in v0.3.4

func (kp *KupoProvider) FetchUTxOs(hash string, index *int) ([]UTxO, error)

type MaestroProvider

type MaestroProvider struct {
	// contains filtered or unexported fields
}

func NewMaestroProvider

func NewMaestroProvider(apiKey string, network Network) *MaestroProvider

func (*MaestroProvider) FetchAddressUTxOs added in v0.3.3

func (ms *MaestroProvider) FetchAddressUTxOs(address string, asset *string) ([]UTxO, error)

TODO: implement FetchAddressUTxOs

func (*MaestroProvider) FetchTxInfo

func (ms *MaestroProvider) FetchTxInfo(hash string) (TransactionInfo, error)

func (*MaestroProvider) FetchUTxOs

func (ms *MaestroProvider) FetchUTxOs(hash string, index *int) ([]UTxO, error)

func (*MaestroProvider) SubmitTx

func (ms *MaestroProvider) SubmitTx(txCbor string) (string, error)

type MsDatum

type MsDatum struct {
	Hash  string `json:"hash"`
	Bytes string `json:"bytes"`
	Json  any    `json:"json"`
}

type Network

type Network string
const (
	Testnet Network = "testnet"
	Preview Network = "preview"
	Preprod Network = "preprod"
	Mainnet Network = "mainnet"
)

func (Network) String

func (n Network) String() string

type OgmiosProvider added in v0.3.4

type OgmiosProvider struct {
	*ogmigo.Client
}

func (*OgmiosProvider) SubmitTx added in v0.3.4

func (o *OgmiosProvider) SubmitTx(txCbor string) (string, error)

type Output

type Output struct {
	Address    string  `json:"address" binding:"required"`
	Amount     []Asset `json:"amount" binding:"required"`
	DataHash   string  `json:"data_hash,omitempty"`
	PlutusData string  `json:"plutus_data,omitempty"`
	ScriptRef  string  `json:"script_ref,omitempty"`
	ScriptHash string  `json:"script_hash,omitempty"`
}

type Protocol

type Protocol struct {
	Epoch                      int
	MinFeeA                    int
	MinFeeB                    int
	MaxBlockSize               int
	MaxTxSize                  int
	MaxBlockHeaderSize         int
	KeyDeposit                 int
	PoolDeposit                int
	Decentralisation           float64
	MinPoolCost                string
	PriceMem                   float64
	PriceStep                  float64
	MaxTxExMem                 string
	MaxTxExSteps               string
	MaxBlockExMem              string
	MaxBlockExSteps            string
	MaxValSize                 int
	CollateralPercent          int
	MaxCollateralInputs        int
	CoinsPerUtxoSize           int
	MinFeeRefScriptCostPerByte int
}

type SubmitTxResult added in v0.3.4

type SubmitTxResult struct {
	Transaction struct {
		ID string `json:"id"`
	} `json:"transaction"`
}

type TransactionInfo

type TransactionInfo struct {
	Index         int
	Block         string
	Hash          string
	Slot          string
	Fees          string
	Size          int
	Deposit       string
	InvalidBefore string
	InvalidAfter  string
}

type UTxO

type UTxO struct {
	Input  Input  `json:"input" binding:"required"`
	Output Output `json:"output" binding:"required"`
}

func BfAddressUtxoToUtxo added in v0.3.2

func BfAddressUtxoToUtxo(bfUtxo blockfrost.AddressUTXO) UTxO

func BfToUtxo

func BfToUtxo(bfUtxo blockfrost.TransactionOutput, hash string) UTxO

func BfToUtxos

func BfToUtxos(bfUtxos []blockfrost.TransactionOutput, hash string) []UTxO

func FindUtxoByIndex

func FindUtxoByIndex(utxos []UTxO, index int) *UTxO

func MakeScriptUtxo

func MakeScriptUtxo(txHash string, outputIndex int, address string, amount []Asset, plutusData string, dataHash string) UTxO

func MsToUtxo

func MsToUtxo(msUtxo msModel.Utxo) UTxO

func MsToUtxos

func MsToUtxos(msUtxos []msModel.Utxo) []UTxO

type Value

type Value struct {
	Value map[string]int64
}

Value provide utility to handle the Cardano value manipulation. It offers certain axioms: 1. No duplication of asset - adding assets with same asset name will increase the quantity of the asset in the same record. 2. No zero and negative entry - the quantity of the asset should not be zero or negative. 3. Sanitization of lovelace asset name - the class handle back and forth conversion of lovelace asset name to empty string. 4. Easy convertion to Cardano data - offer utility to convert into either Mesh Data type and JSON type for its Cardano data representation.

func NewValue

func NewValue() *Value

NewValue create a new Value instance with empty value.

func NewValueFromAssets

func NewValueFromAssets(assets *[]Asset) *Value

NewValueFromAssets - create a new Value instance with the given assets.

func (*Value) AddAsset

func (v *Value) AddAsset(asset *Asset) *Value

AddAsset - Add an asset to the Value class's value record.

func (*Value) AddAssets

func (v *Value) AddAssets(assets *[]Asset) *Value

AddAssets - add multiple assets to the Value class's value record.

func (*Value) Geq

func (v *Value) Geq(other *Value) bool

Geq - check if the value is greater than or equal to another value

func (*Value) Get

func (v *Value) Get(unit string) int64

Get - get the quantity of an asset in the Value class's value record.

func (*Value) IsEmpty

func (v *Value) IsEmpty() bool

IsEmpty - check if the Value class's value record is empty.

func (*Value) Merge

func (v *Value) Merge(values ...*Value) *Value

Merge - merge multiple Value class's value record into the current Value class's value record.

func (*Value) NegateAsset

func (v *Value) NegateAsset(asset *Asset) *Value

NegateAsset - deduct the value amount of an asset from the Value class's value record.

func (*Value) NegateAssets

func (v *Value) NegateAssets(assets *[]Asset) *Value

NegateAssets - deduct the value amount of multiple assets from the Value class's value record.

func (*Value) ToAssets

func (v *Value) ToAssets() *[]Asset

ToAssets - convert the Value class's value record into a list of Asset.

func (*Value) Units

func (v *Value) Units() []string

Units - get the list of asset names in the Value class's value record.

Directories

Path Synopsis
Package builder
Package builder
common
data
Package data
Package data
Package models
Package models
builder_types
Package builder_types
Package builder_types

Jump to

Keyboard shortcuts

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