client

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SerializeBatches

func SerializeBatches(batches []*Batch) []byte

SerializeBatches serializes the given batches to bytes in the form expected by the REST API.

func SerializeTransactions

func SerializeTransactions(transactions []*Transaction) []byte

SerializeTransactions serializes the given transactions to bytes for transmission to a separate batcher.

Types

type Batch

type Batch batch_pb2.Batch

func ParseBatches

func ParseBatches(b []byte) ([]*Batch, error)

ParseBatches deserializes the given bytes into a list of batches. The bytes are assumed to be in the format returned by SerializeBatches.

func (*Batch) ToPb

func (b *Batch) ToPb() *batch_pb2.Batch

type Client

type Client struct {
	Url string
}

func New

func New(url string) *Client

func (*Client) CreateContractAccount

func (c *Client) CreateContractAccount(
	priv []byte, init []byte, perms *EvmPermissions, nonce uint64, gas uint64, wait int) (*ClientResult, error)

CreateContractAccount creates a new contract associated with the account associated with the given private key. The account is initialized with the data in init. If permissions are passed, the account is created with those permissions.

Returns the address of the new account, transaction ID, and receipt.

func (*Client) CreateExternalAccount

func (c *Client) CreateExternalAccount(
	priv, moderator []byte, perms *EvmPermissions, nonce uint64, wait int) (*ClientResult, error)

CreateExternalAccount submits a transaction to create the account with the given private key. If moderator is not nil, the account associated with that key will be used to create the new account. If perms is not nil, the new account is created with the given permissions.

Returns the address of the new account, transaction ID, and receipt.

func (*Client) Get

func (c *Client) Get(address []byte) (*EvmEntry, error)

Get retrieves all data in state associated with the given address. If there isn't anything at the address, returns nil.

func (*Client) GetEvents

func (c *Client) GetEvents(txnID string) (*ClientResult, error)

func (*Client) GetSethReceipt

func (c *Client) GetSethReceipt(txnID string) (*ClientResult, error)

func (*Client) LookupAccountNonce

func (c *Client) LookupAccountNonce(priv []byte) (uint64, error)

func (*Client) MessageCall

func (c *Client) MessageCall(
	priv, to, data []byte, nonce uint64, gas uint64, wait int, chaining_enabled bool) (*ClientResult, error)

MessageCall sends a message call from the account associated with the given private key to the account at the address to. data is used as the input to the contract call.

Returns the output from the EVM call.

func (*Client) SetPermissions

func (c *Client) SetPermissions(priv, to []byte, permissions *EvmPermissions, nonce uint64, wait int) error

SetPermissions updates the permissions of the account at the given address using the account with the given private key.

type ClientResult

type ClientResult struct {
	TransactionID string  `json:",omitempty"`
	Address       []byte  `json:",omitempty"`
	GasUsed       uint64  `json:",omitempty"`
	ReturnValue   []byte  `json:",omitempty"`
	Events        []Event `json:",omitempty"`
}

func (*ClientResult) MarshalJSON

func (r *ClientResult) MarshalJSON() ([]byte, error)

Allows address bytes to be encoded to hex for CLI output

type Encoder

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

func NewEncoder

func NewEncoder(private_key []byte, defaults TransactionParams) *Encoder

NewTransactionEncoder constructs a new encoder which can be used to generate transactions and batches, and to serialize batches for submitting to the REST API.

func (*Encoder) NewBatch

func (self *Encoder) NewBatch(transactions []*Transaction) *Batch

NewBatch creates a new batch from the given transactions created by NewTransaction. It handles the construction and signing of the batch header.

func (*Encoder) NewTransaction

func (self *Encoder) NewTransaction(payload []byte, p TransactionParams) *Transaction

NewTransaction Creates a new transaction and handles the construction and signing of the transaction header.

type ErrorBody

type ErrorBody struct {
	Code    int
	Title   string
	Message string
}

func (*ErrorBody) Error

func (e *ErrorBody) Error() string

func (*ErrorBody) String

func (e *ErrorBody) String() string

type Event

type Event struct {
	EventType  string `json:"event_type"`
	Attributes []struct {
		Key   string
		Value string
	}
	Data string
}

type ReceiptRespBody

type ReceiptRespBody struct {
	Data  []TransactionReceipt
	Link  string
	Head  string
	Error ErrorBody
}

func ParseReceiptBody

func ParseReceiptBody(resp *http.Response) (*ReceiptRespBody, error)

func ParseReceiptBodyData

func ParseReceiptBodyData(buf []byte) (*ReceiptRespBody, error)

type RespBody

type RespBody struct {
	Data  interface{}
	Link  string
	Head  string
	Error ErrorBody
}

func ParseBodyData

func ParseBodyData(buf []byte) (*RespBody, error)

func ParseRespBody

func ParseRespBody(resp *http.Response) (*RespBody, error)

func (*RespBody) String

func (r *RespBody) String() string

type Transaction

type Transaction transaction_pb2.Transaction

Wrap the protobuf types so that they do not need to be imported separately.

func ParseTransactions

func ParseTransactions(b []byte) ([]*Transaction, error)

ParseTransactions deserializes the given bytes into a list of transactions. The bytes are assumed to be in the format returned by SerializeTransactions.

func (*Transaction) Id

func (t *Transaction) Id() string

GetId Returns the Transaction ID which can be used to specify this transaction as a dependency for other transactions.

func (*Transaction) ToPb

type TransactionParams

type TransactionParams struct {
	FamilyName       string
	FamilyVersion    string
	Nonce            string
	BatcherPublicKey string
	Dependencies     []string
	Inputs           []string
	Outputs          []string
}

type TransactionReceipt

type TransactionReceipt struct {
	TransactionId string
	StateChanges  []struct {
		Value   string
		Type    string
		Address string
	}
	Events []Event
	Data   []string
}

Jump to

Keyboard shortcuts

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