web3

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertStringToBigInt

func ConvertStringToBigInt(st string) big.Int

func ConvertStringToInt64

func ConvertStringToInt64(st string) uint64

func EtherToWei

func EtherToWei(etherAmount float64) *big.Int

func EtherToWeiUint64

func EtherToWeiUint64(etherAmount float64) uint64

func GetAddress

func GetAddress(privateKey *ecdsa.PrivateKey) common.Address

func GetAddressFromSignedMessage

func GetAddressFromSignedMessage(message []byte, sig []byte) (common.Address, error)

func GetPublicKey

func GetPublicKey(privateKey *ecdsa.PrivateKey) ecdsa.PublicKey

func ParsePrivateKey

func ParsePrivateKey(privateKey string) (*ecdsa.PrivateKey, error)

func SignMessage

func SignMessage(privateKey *ecdsa.PrivateKey, message []byte) ([]byte, error)

Types

type Contracts

type Contracts struct {
	Token      *token.Token
	Payments   *payments.Payments
	Storage    *storage.Storage
	Users      *users.Users
	JobCreator *jobcreator.Jobcreator
	Mediation  *mediation.Mediation
	Controller *controller.Controller
}

these are the go-binding wrappers for the various deployed contracts

func NewContracts

func NewContracts(
	options Web3Options,
	client *ethclient.Client,
	callOpts *bind.CallOpts,
) (*Contracts, error)

type EventChannelCollection

type EventChannelCollection interface {
	Start(
		sdk *Web3SDK,
		ctx context.Context,
		cm *system.CleanupManager,
	) error
}

type EventChannels

type EventChannels struct {
	Token      *TokenEventChannels
	Payment    *PaymentEventChannels
	Storage    *StorageEventChannels
	JobCreator *JobCreatorEventChannels
	Mediation  *MediationEventChannels
	// contains filtered or unexported fields
}

func NewEventChannels

func NewEventChannels() *EventChannels

func (*EventChannels) Start

func (eventChannels *EventChannels) Start(
	sdk *Web3SDK,
	ctx context.Context,
	cm *system.CleanupManager,
) error

type JobCreatorEventChannels

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

func NewJobCreatorEventChannels

func NewJobCreatorEventChannels() *JobCreatorEventChannels

func (*JobCreatorEventChannels) Start

func (*JobCreatorEventChannels) SubscribeJobAdded

func (t *JobCreatorEventChannels) SubscribeJobAdded(handler func(jobcreator.JobcreatorJobAdded))

type MediationEventChannels

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

func NewMediationEventChannels

func NewMediationEventChannels() *MediationEventChannels

func (*MediationEventChannels) Start

func (*MediationEventChannels) SubscribeMediationRequested

func (m *MediationEventChannels) SubscribeMediationRequested(handler func(mediation.MediationMediationRequested))

type PaymentEventChannels

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

func NewPaymentEventChannels

func NewPaymentEventChannels() *PaymentEventChannels

func (*PaymentEventChannels) Start

func (*PaymentEventChannels) SubscribePayment

func (p *PaymentEventChannels) SubscribePayment(handler func(payments.PaymentsPayment))

type StorageEventChannels

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

func NewStorageEventChannels

func NewStorageEventChannels() *StorageEventChannels

func (*StorageEventChannels) Start

func (*StorageEventChannels) SubscribeDealStateChange

func (t *StorageEventChannels) SubscribeDealStateChange(handler func(storage.StorageDealStateChange))

type TokenEventChannels

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

func NewTokenEventChannels

func NewTokenEventChannels() *TokenEventChannels

func (*TokenEventChannels) Start

func (t *TokenEventChannels) Start(
	sdk *Web3SDK,
	ctx context.Context,
	cm *system.CleanupManager,
) error

func (*TokenEventChannels) SubscribeTransfer

func (t *TokenEventChannels) SubscribeTransfer(handler func(token.TokenTransfer))

type Web3Options

type Web3Options struct {

	// core settings
	RpcURL     string `json:"rpc_url"`
	PrivateKey string `json:"private_key"`
	ChainID    int    `json:"chain_id"`

	// contract addresses
	ControllerAddress string `json:"controller_address"`
	PaymentsAddress   string `json:"payments_address"`
	StorageAddress    string `json:"storage_address"`
	UsersAddress      string `json:"users_address"`
	MediationAddress  string `json:"mediation_address"`
	JobCreatorAddress string `json:"jobcreator_address"`
	TokenAddress      string `json:"token_address"`

	// this is injected by whatever service we are running
	// it's used for logging tx's
	Service system.Service `json:"-"`
}

type Web3SDK

type Web3SDK struct {
	Options      Web3Options
	PrivateKey   *ecdsa.PrivateKey
	Client       *ethclient.Client
	CallOpts     *bind.CallOpts
	TransactOpts *bind.TransactOpts
	Contracts    *Contracts
}

func NewContractSDK

func NewContractSDK(options Web3Options) (*Web3SDK, error)

func (*Web3SDK) AcceptResult

func (sdk *Web3SDK) AcceptResult(
	dealId string,
) (string, error)

func (*Web3SDK) AddResult

func (sdk *Web3SDK) AddResult(
	dealId string,
	resultsId string,
	dataId string,
	instructionCount uint64,
) (string, error)

func (*Web3SDK) AddUserToList

func (sdk *Web3SDK) AddUserToList(
	serviceType uint8,
) error

func (*Web3SDK) Agree

func (sdk *Web3SDK) Agree(
	deal dto.Deal,
) (string, error)

func (*Web3SDK) CheckResult

func (sdk *Web3SDK) CheckResult(
	dealId string,
) (string, error)

func (*Web3SDK) GetAddress

func (sdk *Web3SDK) GetAddress() common.Address

func (*Web3SDK) GetServiceAddresses

func (sdk *Web3SDK) GetServiceAddresses(serviceType string) ([]common.Address, error)

func (*Web3SDK) GetSolverAddresses

func (sdk *Web3SDK) GetSolverAddresses() ([]common.Address, error)

func (*Web3SDK) GetSolverUrl

func (sdk *Web3SDK) GetSolverUrl(address string) (string, error)

func (*Web3SDK) GetUser

func (sdk *Web3SDK) GetUser(
	address common.Address,
) (users.SharedStructsUser, error)

func (*Web3SDK) MediationAcceptResult

func (sdk *Web3SDK) MediationAcceptResult(
	dealId string,
) (string, error)

func (*Web3SDK) MediationRejectResult

func (sdk *Web3SDK) MediationRejectResult(
	dealId string,
) (string, error)

func (*Web3SDK) UpdateUser

func (sdk *Web3SDK) UpdateUser(
	metadataCID string,
	url string,
	roles []uint8,
) error

func (*Web3SDK) WaitTx

func (sdk *Web3SDK) WaitTx(ctx context.Context, tx *types.Transaction) (*types.Receipt, error)

Directories

Path Synopsis
bindings

Jump to

Keyboard shortcuts

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