plasma

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EthCurrency     = "0x0000000000000000000000000000000000000000"
	DefaultMetadata = "0x0000000000000000000000000000000000000000000000000000000000000000"
)

Variables

This section is empty.

Functions

func DisplayBalance

func DisplayBalance(b *WatcherBalanceFromAddress)

log the balance data in a human friendly format

func DisplayGetResponse

func DisplayGetResponse(response *TransactionGetResponse)

Display transaction.get response

func DisplaySubmitResponse

func DisplaySubmitResponse(response *TransactionSubmitResponse)

Display transaction.submit response

func DisplayUTXOS

func DisplayUTXOS(u *WatcherUTXOsFromAddress)

log the UTXO data in a human friendly format

func ProcessExits

func ProcessExits(numberExitsToProcess int64, p ProcessExit)

Calls the processExits in the Plasma smart contract to start processing exits that have completed the challenge period.

func Sign

func Sign(t TransactionSigner) ([][]byte, error)

Sign function takes a transaction signer interface and calls sign

Types

type Block

type Block struct {
	Timestamp int    `json:"timestamp"`
	Hash      string `json:"hash"`
	EthHeight int    `json:"eth_height"`
	Blknum    int    `json:"blknum"`
}

type ByzantineEvents

type ByzantineEvents struct {
	PiggyBack        int
	NonCanonical     int
	UnchallengedExit int
	InvalidExit      int
}

func DisplayByzantineEvents

func DisplayByzantineEvents(b *WatcherStatus) ByzantineEvents

TODO: Display all events in the specs parse byzantine events data based on event names

type ChallengeUTXOData

type ChallengeUTXOData struct {
	Version string `json:"version"`
	Success bool   `json:"success"`
	Data    struct {
		ExitId     *big.Int `json:"exit_id"`
		InputIndex uint8    `json:"input_index"`
		Sig        string   `json:"sig"`
		Txbytes    string   `json:"txbytes"`
	} `json:"data"`
}

func GetChallengeData

func GetChallengeData(watcher string, utxoPosition int) (ChallengeUTXOData, error)

get challenge data from watcher

func (*ChallengeUTXOData) ChallengeInvalidExit

func (c *ChallengeUTXOData) ChallengeInvalidExit(ethereumClient string, contract string, private string)

challenge invalid exit on the root chain

type CreateTransaction

type CreateTransaction struct {
	Owner           string     `json:"owner"`
	Payments        []Payments `json:"payments"`
	Fee             Fee        `json:"fee"`
	Metadata        string     `json:"metadata"`
	WatcherEndpoint string
}

plasma transaction to call via the convenient transaction.create endpoint

func NewCreateTransaction

func NewCreateTransaction() CreateTransaction

NewCreateTransaction returns a new CreateTransaction struct

func (*CreateTransaction) CreateTransaction

func (c *CreateTransaction) CreateTransaction() (*CreateTransactionResponse, error)

CreateTransaction creates a transaction by calling `/transaction.create` endpoint

type CreateTransactionResponse

type CreateTransactionResponse struct {
	Version string `json:"version"`
	Success bool   `json:"success"`
	Data    Data   `json:"data"`
}

type Data

type Data struct {
	Result       string         `json:"result"`
	Transactions []Transactions `json:"transactions"`
	Object       string         `json:"object"`
	Code         string         `json:"code"`
	Description  string         `json:"description"`
}

type Domain

type Domain struct {
	Name              string `json:"name"`
	Salt              string `json:"salt"`
	VerifyingContract string `json:"verifyingContract"`
	Version           string `json:"version"`
}

type EIP712Domain

type EIP712Domain struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type ErrorData

type ErrorData struct {
	Object      string   `json:"object"`
	Code        string   `json:"code"`
	Description string   `json:"description"`
	Messages    Messages `json:"messages"`
}

type Fee

type Fee struct {
	Amount   uint64 `json:"amount"`
	Currency string `json:"currency"`
}

type GetTxData

type GetTxData struct {
	Txindex  int       `json:"txindex"`
	Txhash   string    `json:"txhash"`
	Metadata string    `json:"metadata"`
	Txbytes  string    `json:"txbytes"`
	Block    Block     `json:"block"`
	Inputs   []Inputs  `json:"inputs"`
	Outputs  []Outputs `json:"outputs"`
}

type Input

type Input struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type Input0

type Input0 struct {
	Blknum  int `json:"blknum"`
	Txindex int `json:"txindex"`
	Oindex  int `json:"oindex"`
}

type Input1

type Input1 struct {
	Blknum  int `json:"blknum"`
	Txindex int `json:"txindex"`
	Oindex  int `json:"oindex"`
}

type Input2

type Input2 struct {
	Blknum  int `json:"blknum"`
	Txindex int `json:"txindex"`
	Oindex  int `json:"oindex"`
}

type Input3

type Input3 struct {
	Blknum  int `json:"blknum"`
	Txindex int `json:"txindex"`
	Oindex  int `json:"oindex"`
}

type Inputs

type Inputs struct {
	Blknum   int      `json:"blknum"`
	Txindex  int      `json:"txindex"`
	Oindex   int      `json:"oindex"`
	UtxoPos  *big.Int `json:"utxo_pos"`
	Owner    string   `json:"owner"`
	Currency string   `json:"currency"`
	Amount   float64  `json:"amount"`
}

type InvalidExitDetails

type InvalidExitDetails struct {
	EthHeight int      `json:"eth_height"`
	UtxoPos   *big.Int `json:"utxo_pos"`
	Owner     string   `json:"owner"`
	Currency  string   `json:"currency"`
	Amount    float64  `json:"amount"`
}

type Message

type Message struct {
	Input0   Input0  `json:"input0"`
	Input1   Input1  `json:"input1"`
	Input2   Input2  `json:"input2"`
	Input3   Input3  `json:"input3"`
	Output0  Output0 `json:"output0"`
	Output1  Output1 `json:"output1"`
	Output2  Output2 `json:"output2"`
	Output3  Output3 `json:"output3"`
	Metadata string  `json:"metadata"`
}

type Messages

type Messages struct {
	ErrorKey string `json:"error_key"`
}

type Output

type Output struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type Output0

type Output0 struct {
	Owner    string  `json:"owner"`
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount"`
}

type Output1

type Output1 struct {
	Owner    string  `json:"owner"`
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount"`
}

type Output2

type Output2 struct {
	Owner    string  `json:"owner"`
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount"`
}

type Output3

type Output3 struct {
	Owner    string  `json:"owner"`
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount"`
}

type Outputs

type Outputs struct {
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`
	Owner    string  `json:"owner"`
}

type Payments

type Payments struct {
	Amount   uint64 `json:"amount"`
	Currency string `json:"currency"`
	Owner    string `json:"owner"`
}

type PlasmaDeposit

type PlasmaDeposit struct {
	PrivateKey string
	Client     string
	Contract   string
	Amount     uint64
	Owner      string
	Currency   string
}

func (*PlasmaDeposit) DepositToPlasmaContract

func (d *PlasmaDeposit) DepositToPlasmaContract()

Deposit ETH into the already deployed Plasma MoreVP contract on Ethereum

type PlasmaTransaction

type PlasmaTransaction interface {
	Submit() (*TransactionSubmitResponse, error)
}

type ProcessExit

type ProcessExit struct {
	Contract   string
	PrivateKey string
	Token      string
	Client     string
}

type SingleSigner

type SingleSigner struct {
	ToSign     []byte
	PrivateKey string
}

func (SingleSigner) Sign

func (s SingleSigner) Sign() ([][]byte, error)

Sign will sign a has with a single private key

type StandardExit

type StandardExit struct {
	UtxoPosition int
	PrivateKey   string
	Contract     string
	Client       string
}

func (*StandardExit) StartStandardExit

func (s *StandardExit) StartStandardExit(watcher string)

Start a standard exit from user provided UTXO & private key

type StandardExitUTXOData

type StandardExitUTXOData struct {
	Version string `json:"version"`
	Success bool   `json:"success"`
	Data    struct {
		UtxoPos *big.Int `json:"utxo_pos"`
		Txbytes string   `json:"txbytes"`
		Proof   string   `json:"proof"`
	} `json:"data"`
}

func GetUTXOExitData

func GetUTXOExitData(watcher string, utxoPosition int) (StandardExitUTXOData, error)

Retrieve the UTXO exit data from the UTXO position

func (*StandardExitUTXOData) StartStandardExit

func (s *StandardExitUTXOData) StartStandardExit(ethereumClient string, contract string, private string)

Start standard exit by calling the method in the smart contract

type Transaction

type Transaction struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type TransactionGetResponse

type TransactionGetResponse struct {
	Version string    `json:"version"`
	Success bool      `json:"success"`
	Data    GetTxData `json:"data"`
}

func GetTransaction

func GetTransaction(txHash string, watcher string) (*TransactionGetResponse, error)

Get transaction

type TransactionSigner

type TransactionSigner interface {
	Sign() ([][]byte, error)
}

type TransactionSubmitFailureResponse

type TransactionSubmitFailureResponse struct {
	Version string `json:"version"`
	Success bool   `json:"success"`
	Data    struct {
		Object      string `json:"object"`
		Code        string `json:"code"`
		Description string `json:"description"`
		Messages    struct {
			ErrorKey string `json:"error_key"`
		} `json:"messages"`
	} `json:"data"`
}

type TransactionSubmitResponse

type TransactionSubmitResponse struct {
	Version string `json:"version"`
	Success bool   `json:"success"`
	Data    struct {
		Blknum      int    `json:"blknum"`
		Txindex     int    `json:"txindex"`
		Txhash      string `json:"txhash"`
		Object      string `json:"object"`
		Code        string `json:"code"`
		Description string `json:"description"`
	} `json:"data"`
}

func Submit

Submit function takes a plasma transaction interface and calls Submit

type Transactions

type Transactions struct {
	Inputs    []Inputs  `json:"inputs"`
	Outputs   []Outputs `json:"outputs"`
	Fee       Fee       `json:"fee"`
	Metadata  string    `json:"metadata"`
	Txbytes   string    `json:"txbytes"`
	SignHash  string    `json:"sign_hash"`
	TypedData TypedData `json:"typed_data"`
}

func (*Transactions) GetToSignHash

func (t *Transactions) GetToSignHash() string

GetToSignHash returns a typed data hash to be signed

func (*Transactions) GetTypedData

func (t *Transactions) GetTypedData() TypedData

GetTypedData returns the typed data

type TypedData

type TypedData struct {
	Types       Types   `json:"types"`
	PrimaryType string  `json:"primaryType"`
	Domain      Domain  `json:"domain"`
	Message     Message `json:"message"`
}

type TypedTransaction

type TypedTransaction struct {
	Domain          Domain   `json:"domain"`
	Message         Message  `json:"message"`
	Signatures      []string `json:"signatures"`
	WatcherEndpoint string
}

func CreateTypedTransaction

func CreateTypedTransaction(d Domain, m Message, sigs [][]byte, w string) (*TypedTransaction, error)

CreateTypedTransaction takse domain, message and signatures, returns a typed transaction

func (TypedTransaction) Submit

Submit takes a typed transaction and it to "transaction.submit_typed/" endpoint

type Types

type Types struct {
	EIP712Domain []EIP712Domain `json:"EIP712Domain"`
	Transaction  []Transaction  `json:"Transaction"`
	Input        []Input        `json:"Input"`
	Output       []Output       `json:"Output"`
}

type WatcherBalanceFromAddress

type WatcherBalanceFromAddress struct {
	Version string `json:"version"`
	Success bool   `json:"success"`
	Data    []struct {
		Currency string  `json:"currency"`
		Amount   float64 `json:"amount"`
	} `json:"data"`
}

balance of an address returned from watcher

func GetBalance

func GetBalance(address string, watcher string) (*WatcherBalanceFromAddress, error)

Get balance for a certain address

type WatcherStatus

type WatcherStatus struct {
	Version string `json:"version"`
	Success bool   `json:"success"`
	Data    struct {
		LastValidatedChildBlockNumber int  `json:"last_validated_child_block_number"`
		LastMinedChildBlockTimestamp  int  `json:"last_mined_child_block_timestamp"`
		LastMinedChildBlockNumber     int  `json:"last_mined_child_block_number"`
		EthSyncing                    bool `json:"eth_syncing"`
		ByzantineEvents               []struct {
			Event   string                 `json:"event"`
			Details map[string]interface{} `json:"details"`
		} `json:"byzantine_events"`
	} `json:"data"`
}

only displaying invalid exit details for now

func GetWatcherStatus

func GetWatcherStatus(w string) (*WatcherStatus, error)

Get the Watcher's status

type WatcherUTXOsFromAddress

type WatcherUTXOsFromAddress struct {
	Version string `json:"version"`
	Success bool   `json:"success"`
	Data    []struct {
		UtxoPos  *big.Int `json:"utxo_pos"`
		Txindex  int      `json:"txindex"`
		Owner    string   `json:"owner"`
		Oindex   int      `json:"oindex"`
		Currency string   `json:"currency"`
		Blknum   int      `json:"blknum"`
		Amount   float64  `json:"amount"`
	} `json:"data"`
}

UTXOs of an address returned from watcher

func GetUTXOsFromAddress

func GetUTXOsFromAddress(address string, w string) (*WatcherUTXOsFromAddress, error)

Retrieve the UTXOs associated with an address from the Watcher

Jump to

Keyboard shortcuts

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