subi

package
v0.17.5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 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 {
	NewIdentityFromSr25519Phrase(mnemonic string) (substrate.Identity, error)
	AcceptTermsAndConditions(identity substrate.Identity, docLink string, docHash string) error
	CreateTwin(identity substrate.Identity, relay string, pk []byte) (uint32, error)
	CreateRentContract(identity substrate.Identity, nodeID uint32, solutionProviderID *uint64) (uint64, error)
	Transfer(amount uint64, source substrate.Identity, destinationPk []byte) error

	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)
	GetNode(id uint32) (*substrate.Node, 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)
	GetTFTBillingRate() (rate types.U32, err error)
	GetPricingPolicy(policyID uint32) (pricingPolicy substrate.PricingPolicy, err error)
	GetTwinPK(twinID uint32) ([]byte, error)
	GetContractIDByNameRegistration(name string) (uint64, error)
	GetContractWithHash(identity substrate.Identity, node uint32, hash []byte) (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
	GetContractPaymentState(id uint64) (substrate.ContractPaymentState, error)
	GetContractBillingInfo(id uint64) (substrate.ContractBillingInfo, error)
	GetNodeContractResources(id uint64) (substrate.NodeContractResources, error)
	GetNodeRentContract(id uint32) (uint64, error)
	GetDedicatedNodePrice(nodeID uint32) (uint64, error)
	GetNodeContracts(nodeID uint32) ([]types.U64, 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) AcceptTermsAndConditions added in v0.17.4

func (s *SubstrateImpl) AcceptTermsAndConditions(identity substrate.Identity, docLink string, docHash string) error

AcceptTermsAndConditions accepts terms and conditions

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) CreateRentContract added in v0.17.4

func (s *SubstrateImpl) CreateRentContract(identity substrate.Identity, nodeID uint32, solutionProviderID *uint64) (uint64, error)

CreateRentContract creates a rent contract

func (*SubstrateImpl) CreateTwin added in v0.17.4

func (s *SubstrateImpl) CreateTwin(identity substrate.Identity, relay string, pk []byte) (uint32, error)

CreateTwin creates a twin and returns its twin ID

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) GetContractBillingInfo added in v0.16.10

func (s *SubstrateImpl) GetContractBillingInfo(id uint64) (substrate.ContractBillingInfo, error)

Get contract billing info

func (*SubstrateImpl) GetContractIDByNameRegistration

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

GetContractIDByNameRegistration returns contract ID using its name

func (*SubstrateImpl) GetContractPaymentState added in v0.16.10

func (s *SubstrateImpl) GetContractPaymentState(id uint64) (substrate.ContractPaymentState, error)

Get contract payment state

func (*SubstrateImpl) GetContractWithHash added in v0.17.2

func (s *SubstrateImpl) GetContractWithHash(identity substrate.Identity, node uint32, hash []byte) (uint64, error)

GetContractWithHash gets a contract by hash

func (*SubstrateImpl) GetDedicatedNodePrice added in v0.16.10

func (s *SubstrateImpl) GetDedicatedNodePrice(nodeID uint32) (uint64, error)

func (*SubstrateImpl) GetNode added in v0.16.10

func (s *SubstrateImpl) GetNode(id uint32) (*substrate.Node, error)

Get node

func (*SubstrateImpl) GetNodeContractResources added in v0.16.10

func (s *SubstrateImpl) GetNodeContractResources(id uint64) (substrate.NodeContractResources, error)

Get node contract resources by contract Id

func (*SubstrateImpl) GetNodeContracts added in v0.16.10

func (s *SubstrateImpl) GetNodeContracts(nodeID uint32) ([]types.U64, error)

func (*SubstrateImpl) GetNodeRentContract added in v0.16.10

func (s *SubstrateImpl) GetNodeRentContract(id uint32) (uint64, error)

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) GetTFTBillingRate added in v0.16.10

func (s *SubstrateImpl) GetTFTBillingRate() (rate types.U32, err error)

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) NewIdentityFromSr25519Phrase added in v0.17.4

func (s *SubstrateImpl) NewIdentityFromSr25519Phrase(mnemonic string) (substrate.Identity, error)

NewIdentityFromSr25519Phrase returns the identity from mnemonic

func (*SubstrateImpl) Transfer added in v0.17.4

func (s *SubstrateImpl) Transfer(amount uint64, source substrate.Identity, destinationPk []byte) error

Transfer transfers an amount from source to destination

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