subi

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package subi for substrate client

Package subi for substrate client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contract

type Contract struct {
	*substrate.Contract
}

Contract is for contract implementation

func (*Contract) IsCreated

func (c *Contract) IsCreated() bool

IsCreated checks if contract is created

func (*Contract) IsDeleted

func (c *Contract) IsDeleted() bool

IsDeleted checks if contract is deleted

func (*Contract) PublicIPCount

func (c *Contract) PublicIPCount() uint32

PublicIPCount returns contract's public IPs count

func (*Contract) TwinID

func (c *Contract) TwinID() uint32

TwinID returns contract's twin ID

type Manager

type Manager struct {
	substrate.Manager
}

Manager is substrate manager struct

func NewManager

func NewManager(url ...string) Manager

NewManager returns a new substrate manager

func (*Manager) SubstrateExt

func (m *Manager) SubstrateExt() (*SubstrateImpl, error)

SubstrateExt returns a substrate implementation to be used

type ManagerInterface

type ManagerInterface interface {
	substrate.Manager
	SubstrateExt() (SubstrateImpl, error)
}

ManagerInterface for substrate manager

type SubstrateExt

type SubstrateExt interface {
	CancelContract(identity substrate.Identity, contractID uint64) error
	CreateNodeContract(identity substrate.Identity, node uint32, body string, hash string, publicIPs uint32, solutionProviderID *uint64) (uint64, error)
	UpdateNodeContract(identity substrate.Identity, contract uint64, body string, hash string) (uint64, error)
	Close()
	GetTwinByPubKey(pk []byte) (uint32, error)

	EnsureContractCanceled(identity substrate.Identity, contractID uint64) error
	DeleteInvalidContracts(contracts map[uint32]uint64) error
	IsValidContract(contractID uint64) (bool, error)
	InvalidateNameContract(
		ctx context.Context,
		identity substrate.Identity,
		contractID uint64,
		name string,
	) (uint64, error)
	GetContract(id uint64) (Contract, error)
	GetNodeTwin(id uint32) (uint32, error)
	CreateNameContract(identity substrate.Identity, name string) (uint64, error)
	GetAccount(identity substrate.Identity) (substrate.AccountInfo, error)
	GetBalance(identity substrate.Identity) (balance substrate.Balance, err error)
	GetTFTPrice() (balance types.U32, err error)
	GetPricingPolicy(policyID uint32) (pricingPolicy substrate.PricingPolicy, err error)
	GetTwinPK(twinID uint32) ([]byte, error)
	GetContractIDByNameRegistration(name string) (uint64, error)
	BatchCreateContract(identity substrate.Identity, contractsData []substrate.BatchCreateContractData) ([]uint64, *int, error)
	BatchAllCreateContract(identity substrate.Identity, contractsData []substrate.BatchCreateContractData) ([]uint64, error)
	BatchCancelContract(identity substrate.Identity, contracts []uint64) error
}

SubstrateExt interface for substrate client

type SubstrateImpl

type SubstrateImpl struct {
	*substrate.Substrate
	// contains filtered or unexported fields
}

SubstrateImpl struct to use dev substrate

func (*SubstrateImpl) BatchAllCreateContract

func (s *SubstrateImpl) BatchAllCreateContract(identity substrate.Identity, contractsData []substrate.BatchCreateContractData) ([]uint64, error)

BatchAllCreateContract creates a batch of contracts atomically

func (*SubstrateImpl) BatchCancelContract

func (s *SubstrateImpl) BatchCancelContract(identity substrate.Identity, contracts []uint64) error

BatchCancelContract cancels a batch of contracts

func (*SubstrateImpl) BatchCreateContract

func (s *SubstrateImpl) BatchCreateContract(identity substrate.Identity, contractsData []substrate.BatchCreateContractData) ([]uint64, *int, error)

BatchCreateContract creates a batch of contracts non-atomically

func (*SubstrateImpl) CancelContract

func (s *SubstrateImpl) CancelContract(identity substrate.Identity, contractID uint64) error

CancelContract cancels a contract

func (*SubstrateImpl) Close

func (s *SubstrateImpl) Close()

Close closes substrate

func (*SubstrateImpl) CreateNameContract

func (s *SubstrateImpl) CreateNameContract(identity substrate.Identity, name string) (uint64, error)

CreateNameContract creates a new name contract

func (*SubstrateImpl) CreateNodeContract

func (s *SubstrateImpl) CreateNodeContract(identity substrate.Identity, node uint32, body string, hash string, publicIPs uint32, solutionProviderID *uint64) (uint64, error)

CreateNodeContract creates a new node contract

func (*SubstrateImpl) DeleteInvalidContracts

func (s *SubstrateImpl) DeleteInvalidContracts(contracts map[uint32]uint64) error

DeleteInvalidContracts deletes invalid contracts

func (*SubstrateImpl) EnsureContractCanceled

func (s *SubstrateImpl) EnsureContractCanceled(identity substrate.Identity, contractID uint64) error

EnsureContractCanceled ensures a canceled contract

func (*SubstrateImpl) GetAccount

func (s *SubstrateImpl) GetAccount(identity substrate.Identity) (substrate.AccountInfo, error)

GetAccount returns the user's account

func (*SubstrateImpl) GetBalance

func (s *SubstrateImpl) GetBalance(identity substrate.Identity) (balance substrate.Balance, err error)

GetBalance returns the user's balance

func (*SubstrateImpl) GetContract

func (s *SubstrateImpl) GetContract(contractID uint64) (Contract, error)

GetContract returns a contract given its ID

func (*SubstrateImpl) GetContractIDByNameRegistration

func (s *SubstrateImpl) GetContractIDByNameRegistration(name string) (uint64, error)

GetContractIDByNameRegistration returns contract ID using its name

func (*SubstrateImpl) GetNodeTwin

func (s *SubstrateImpl) GetNodeTwin(nodeID uint32) (uint32, error)

GetNodeTwin returns the twin ID for a node ID

func (*SubstrateImpl) GetPricingPolicy

func (s *SubstrateImpl) GetPricingPolicy(policyID uint32) (pricingPolicy substrate.PricingPolicy, err error)

GetPricingPolicy returns a pricing policy

func (*SubstrateImpl) GetTFTPrice

func (s *SubstrateImpl) GetTFTPrice() (balance types.U32, err error)

GetTFTPrice returns the TFT's price

func (*SubstrateImpl) GetTwinPK

func (s *SubstrateImpl) GetTwinPK(id uint32) ([]byte, error)

GetTwinPK returns twin's public key

func (*SubstrateImpl) InvalidateNameContract

func (s *SubstrateImpl) InvalidateNameContract(
	ctx context.Context,
	identity substrate.Identity,
	contractID uint64,
	name string,
) (uint64, error)

InvalidateNameContract invalidate a name contract

func (*SubstrateImpl) IsValidContract

func (s *SubstrateImpl) IsValidContract(contractID uint64) (bool, error)

IsValidContract checks if a contract is invalid

func (*SubstrateImpl) UpdateNodeContract

func (s *SubstrateImpl) UpdateNodeContract(identity substrate.Identity, contract uint64, body string, hash string) (uint64, error)

UpdateNodeContract updates a new name contract

Jump to

Keyboard shortcuts

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