types

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ED25519   = 0
	SECP256K1 = 1
)

Variables

This section is empty.

Functions

func CombineHash

func CombineHash(hash1 []byte, hash2 []byte) []byte

Types

type AccessKey

type AccessKey struct {
	Nonce      uint64
	Permission AccessKeyPermission
}

type AccessKeyPermission

type AccessKeyPermission struct {
	Enum         borsh.Enum `borsh_enum:"true"`
	FunctionCall FunctionCallPermission
	FullAccess   borsh.Enum
}

type AccessKeyResponse

type AccessKeyResponse struct {
	Nonce       int64  `json:"nonce"`
	Permission  string `json:"permission"`
	BlockHeight int64  `json:"block_height"`
	BlockHash   string `json:"block_hash"`
	Error       string `json:"error"`
}

type Account

type Account struct {
	Amount        BigInt     `json:"amount"`
	Locked        BigInt     `json:"locked"`
	CodeHash      CryptoHash `json:"code_hash"`
	StorageUsage  int64      `json:"storage_usage"`
	StoragePaidAt int64      `json:"storage_paid_at"`
	Height        int64      `json:"block_height"`
	BlockHash     CryptoHash `json:"block_hash"`
}

type AccountDoesNotExist

type AccountDoesNotExist struct {
	AccountId AccountId `json:"account_id"`
}

type AccountId

type AccountId string

type Action

type Action struct {
	Enum           borsh.Enum `borsh_enum:"true"` // treat struct as complex enum when serializing/deserializing
	CreateAccount  borsh.Enum
	DeployContract DeployContract
	FunctionCall   FunctionCall
	Transfer       Transfer
	Stake          Stake
	AddKey         AddKey
	DeleteKey      DeleteKey
	DeleteAccount  DeleteAccount
}

type ActionError

type ActionError struct {
	Index uint64 `json:"index"`
	Kind  Kind   `json:"kind"`
}

type ActionView

type ActionView struct {
	Enum           borsh.Enum `borsh_enum:"true"` // treat struct as complex enum when serializing/deserializing
	CreateAccount  borsh.Enum
	DeployContract DeployContract
	FunctionCall   FunctionCallView
	Transfer       Transfer
	Stake          Stake
	AddKey         AddKey
	DeleteKey      DeleteKey
	DeleteAccount  DeleteAccount
}

type AddKey

type AddKey struct {
	PublicKey PublicKey
	AccessKey AccessKey
}

type ApprovalMessage

type ApprovalMessage struct {
	Type                []byte
	PreviousBlockHash   CryptoHash
	PreviousBlockHeight int64
	TargetHeight        int64
}

type BigInt

type BigInt big.Int

func NewBigInt

func NewBigInt(bigInt string) BigInt

func (*BigInt) UnmarshalJSON

func (b *BigInt) UnmarshalJSON(p []byte) error

type Block

type Block struct {
	Author string  `json:"author"`
	Header Header  `json:"header"`
	Chunks []Chunk `json:"chunks"`
}

func (*Block) ComputeHash

func (b *Block) ComputeHash(PreviousBlockHash []byte, innerLite HeaderInnerLite, innerRest HeaderInnerRest) ([]byte, error)

func (*Block) ComputeInnerHash

func (b *Block) ComputeInnerHash(innerLite HeaderInnerLite, innerRest HeaderInnerRest) ([]byte, error)

func (*Block) Hash

func (b *Block) Hash() *CryptoHash

func (*Block) Height

func (b *Block) Height() int64

func (*Block) InnerLite

func (b *Block) InnerLite() HeaderInnerLite

func (*Block) InnerRest

func (b *Block) InnerRest() HeaderInnerRest

func (*Block) RlpSerialize

func (b *Block) RlpSerialize() ([]byte, error)

func (*Block) SerializableHeader

func (b *Block) SerializableHeader() SerializableHeader

type BlockNotification

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

func NewBlockNotification

func NewBlockNotification(offset int64) *BlockNotification

func (*BlockNotification) Block

func (bn *BlockNotification) Block() *Block

func (*BlockNotification) Offset

func (bn *BlockNotification) Offset() int64

func (*BlockNotification) Receipts

func (bn *BlockNotification) Receipts() []*chain.Receipt

func (*BlockNotification) SetBlock

func (bn *BlockNotification) SetBlock(block Block)

func (*BlockNotification) SetReceipts

func (bn *BlockNotification) SetReceipts(receipts []*chain.Receipt)

type BlockProducer

type BlockProducer struct {
	ValidatorStakeStructVersion ValidatorStakeStructVersion `json:"validator_stake_struct_version"`
	AccountId                   AccountId                   `json:"account_id"`
	PublicKey                   PublicKey                   `json:"public_key"`
	Stake                       BigInt                      `json:"stake"`
}

type BmcStatus

type BmcStatus struct {
	TxSeq            uint64    `json:"tx_seq"`
	RxSeq            uint64    `json:"rx_seq"`
	Verifier         AccountId `json:"verifier"`
	BMRIndex         uint      `json:"relay_index"`
	RotateHeight     uint64    `json:"rotate_height"`
	RotateTerm       uint      `json:"rotate_term"`
	DelayLimit       uint      `json:"delay_limit"`
	MaxAggregation   uint      `json:"max_aggregation"`
	CurrentHeight    uint64    `json:"current_height"`
	RxHeight         uint64    `json:"rx_height"`
	RxHeightSrc      uint64    `json:"rx_height_src"`
	BlockIntervalSrc uint      `json:"block_interval_src"`
	BlockIntervalDst uint      `json:"block_interval_dst"`
}

type BmvStatus

type BmvStatus struct {
	Height     int64 `json:"mta_height"`
	Offset     int64 `json:"mta_offset"`
	LastHeight int64 `json:"last_height"`
}

type CallFunction

type CallFunction struct {
	RequestType  string    `json:"request_type"`
	Finality     string    `json:"finality"`
	AccountId    AccountId `json:"account_id"`
	MethodName   string    `json:"method_name"`
	ArgumentsB64 string    `json:"args_base64"`
}

type CallFunctionResponse

type CallFunctionResponse struct {
	Result      []byte `json:"result"`
	BlockHeight int64  `json:"block_height"`
	BlockHash   string `json:"block_hash"`
}

type Cause

type Cause struct {
	Type        string     `json:"type"`
	ReceiptHash CryptoHash `json:"receipt_hash"`
}

type ChainStatus

type ChainStatus struct {
	ChainId  string        `json:"chain_id"`
	SyncInfo ChainSyncInfo `json:"sync_info"`
}

type ChainSyncInfo

type ChainSyncInfo struct {
	LatestBlockHash   CryptoHash `json:"latest_block_hash"`
	LatestBlockHeight int64      `json:"latest_block_height"`
	LatestBlockTime   string     `json:"latest_block_time"`
	Syncing           bool       `json:"syncing"`
}

type Change

type Change struct {
	Cause Cause      `json:"cause"`
	Type  string     `json:"type"`
	Data  ChangeData `json:"change"`
}

type ChangeData

type ChangeData struct {
	AccountId   AccountId `json:"account_id"`
	KeyBase64   string    `json:"key_base64"`
	ValueBase64 string    `json:"value_base64"`
}

type Chunk

type Chunk struct {
	ChunkHash            CryptoHash `json:"chunk_hash"`
	PreviousBlockHash    CryptoHash `json:"prev_block_hash"`
	OutcomeRoot          CryptoHash `json:"outcome_root"`
	PrevStateRoot        CryptoHash `json:"prev_state_root"`
	EncodedMerkleRoot    CryptoHash `json:"encoded_merkle_root"`
	EncodedLength        uint       `json:"encoded_length"`
	HeightCreated        uint       `json:"height_created"`
	HeightIncluded       uint       `json:"height_included"`
	ShardId              uint       `json:"shard_id"`
	OutgoingReceiptsRoot CryptoHash `json:"outgoing_receipts_root"`
	TxRoot               CryptoHash `json:"tx_root"`
	Signature            Signature  `json:"signature"`
}

type ChunkHeader

type ChunkHeader struct {
	Header       Chunk         `json:"header"`
	Transactions []Transaction `json:"transactions"`
}

type ContractStateChange

type ContractStateChange struct {
	BlockHash CryptoHash `json:"block_hash"`
	Changes   []Change   `json:"changes"`
}

type CryptoHash

type CryptoHash [32]byte

func NewCryptoHash

func NewCryptoHash(hash string) CryptoHash

func (*CryptoHash) Base58Encode

func (c *CryptoHash) Base58Encode() string

func (*CryptoHash) UnmarshalJSON

func (c *CryptoHash) UnmarshalJSON(p []byte) error

type DeleteAccount

type DeleteAccount struct {
	BeneficiaryID string
}

type DeleteKey

type DeleteKey struct {
	PublicKey PublicKey
}

type DeployContract

type DeployContract struct {
	Code []byte
}

type ExecutionOutcomeView

type ExecutionOutcomeView struct {
	Logs        []string        `json:"logs"`
	ReceiptIds  []CryptoHash    `json:"receipt_ids"`
	GasBurnt    uint64          `json:"gas_burnt"`
	TokensBurnt string          `json:"tokens_burnt"`
	ExecutorId  string          `json:"executor_id"`
	Status      ExecutionStatus `json:"status"`
}

type ExecutionOutcomeWithIdView

type ExecutionOutcomeWithIdView struct {
	Proofs    MerklePath           `json:"proof"`
	BlockHash CryptoHash           `json:"block_hash"`
	ReceiptId CryptoHash           `json:"id"`
	Outcome   ExecutionOutcomeView `json:"outcome"`
}

type ExecutionStatus

type ExecutionStatus struct {
	SuccessValue     string     `json:"SuccessValue"`
	SuccessReceiptId CryptoHash `json:"SuccessReceiptId"`
	Failure          Failure    `json:"Failure"`
	Unknown          string     `json:"Unknown"`
}

type Failure

type Failure struct {
	ActionError ActionError `json:"ActionError"`
}

TODO: Add More Errors

type FunctionCall

type FunctionCall struct {
	MethodName string
	Args       []byte
	Gas        uint64
	Deposit    big.Int
}

type FunctionCallError

type FunctionCallError struct {
	ExecutionError string `json:"ExecutionError"`
}

type FunctionCallPermission

type FunctionCallPermission struct {
	Allowance   *big.Int
	ReceiverId  string
	MethodNames []string
}

type FunctionCallView

type FunctionCallView struct {
	MethodName string
	Args       []byte
	Gas        uint64
	Deposit    BigInt
}
type Header struct {
	Height                int64           `json:"height"`
	PreviousHeight        int64           `json:"prev_height"`
	EpochId               CryptoHash      `json:"epoch_id"`
	NextEpochId           CryptoHash      `json:"next_epoch_id"`
	Hash                  CryptoHash      `json:"hash"`
	PreviousBlockHash     CryptoHash      `json:"prev_hash"`
	PreviousStateRoot     CryptoHash      `json:"prev_state_root"`
	ChunkReceiptsRoot     CryptoHash      `json:"chunk_receipts_root"`
	ChunkHeadersRoot      CryptoHash      `json:"chunk_headers_root"`
	ChunkTransactionRoot  CryptoHash      `json:"chunk_tx_root"`
	OutcomeRoot           CryptoHash      `json:"outcome_root"`
	ChunksIncluded        uint8           `json:"chunks_included"`
	ChallengesRoot        []byte          `json:"challenges_root"`
	Timestamp             Timestamp       `json:"timestamp_nanosec"`
	RandomValue           CryptoHash      `json:"random_value"`
	ValidatorProposals    []BlockProducer `json:"validator_proposals"`
	ChunkMask             []bool          `json:"chunk_mask"`
	GasPrice              BigInt          `json:"gas_price"`
	BlockOrdinal          uint64          `json:"block_ordinal"`
	TotalSupply           BigInt          `json:"total_supply"`
	ChallengesResult      []string        `json:"challenges_result"`
	LastFinalBlock        CryptoHash      `json:"last_final_block"`
	LastDSFinalBlock      CryptoHash      `json:"last_ds_final_block"`
	NextBlockProducerHash CryptoHash      `json:"next_bp_hash"`
	BlockMerkleRoot       CryptoHash      `json:"block_merkle_root"`
	EpochSyncDataHash     CryptoHash      `json:"epoch_sync_data_hash"`
	Approvals             []Signature     `json:"approvals"`
	Signature             Signature       `json:"signature"`
	LatestProtocolVersion uint32          `json:"latest_protocol_version"`
}

type HeaderInnerLite

type HeaderInnerLite struct {
	Height                uint64
	EpochId               [32]byte
	NextEpochId           [32]byte
	PreviousStateRoot     [32]byte
	OutcomeRoot           [32]byte
	Timestamp             uint64
	NextBlockProducerHash [32]byte
	BlockMerkleRoot       [32]byte
}

func (HeaderInnerLite) BorshSerialize

func (h HeaderInnerLite) BorshSerialize() ([]byte, error)

type HeaderInnerRest

type HeaderInnerRest struct {
	ChunkReceiptsRoot     [32]byte
	ChunkHeadersRoot      [32]byte
	ChunkTransactionRoot  [32]byte
	ChallengesRoot        []byte
	RandomValue           [32]byte
	ValidatorProposals    []BlockProducer
	ChunkMask             []bool
	GasPrice              BigInt
	TotalSupply           BigInt
	ChallengesResult      []string
	LastFinalBlock        [32]byte
	LastDSFinalBlock      [32]byte
	BlockOrdinal          uint64
	PreviousHeight        uint64
	EpochSyncDataHash     [32]byte
	Approvals             []Signature
	LatestProtocolVersion uint32
}

func (HeaderInnerRest) BorshSerialize

func (h HeaderInnerRest) BorshSerialize() ([]byte, error)

type Kind

type Kind struct {
	FunctionCallError   FunctionCallError   `json:"FunctionCallError"`
	AccountDoesNotExist AccountDoesNotExist `json:"AccountDoesNotExist"`
}

type MerklePath

type MerklePath []MerklePathItem

type MerklePathItem

type MerklePathItem struct {
	Hash      CryptoHash `json:"hash"`
	Direction string     `json:"direction"`
}

type NextBlockProducers

type NextBlockProducers []BlockProducer

func (*NextBlockProducers) UnmarshalJSON

func (nbps *NextBlockProducers) UnmarshalJSON(p []byte) error

type PublicKey

type PublicKey struct {
	KeyType uint8
	Data    [32]byte
}

func NewPublicKeyFromED25519

func NewPublicKeyFromED25519(pk ed25519.PublicKey) PublicKey

func (*PublicKey) Base58Encode

func (pk *PublicKey) Base58Encode() string

func (*PublicKey) UnmarshalJSON

func (pk *PublicKey) UnmarshalJSON(p []byte) error

type ReceiptProof

type ReceiptProof struct {
	OutComeProof     ExecutionOutcomeWithIdView `json:"outcome_proof"`
	OutComeRootProof MerklePath                 `json:"outcome_root_proof"`
	BlockProof       MerklePath                 `json:"block_proof"`
}

type SerializableHeader

type SerializableHeader struct {
	PreviousBlockHash [32]byte
	InnerLite         HeaderInnerLite
	InnerRest         HeaderInnerRest
	Signature         Signature
}

type Signature

type Signature struct {
	KeyType uint8
	Data    [64]byte
}

func (Signature) Base58Encode

func (s Signature) Base58Encode() string

func (*Signature) Bytes

func (s *Signature) Bytes() []byte

func (*Signature) UnmarshalJSON

func (s *Signature) UnmarshalJSON(p []byte) error

type Stake

type Stake struct {
	Stake     big.Int
	PublicKey PublicKey
}

type Timestamp

type Timestamp uint64

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(p []byte) error

type Transaction

type Transaction struct {
	SignerId   AccountId `json:"signer_id"`
	PublicKey  PublicKey `json:"public_key"`
	Nonce      int       `json:"nonce"`
	ReceiverId AccountId `json:"receiver_id"`
	BlockHash  CryptoHash
	Actions    []Action   `json:"actions"` // TODO: ActionView
	Signature  Signature  `json:"signature"`
	Txid       CryptoHash `json:"hash"`
}

func (*Transaction) Payload

func (t *Transaction) Payload(wallet *wallet.NearWallet) (string, error)

type TransactionResult

type TransactionResult struct {
	Status             ExecutionStatus              `json:"status"`
	Transaction        TransactionView              `json:"transaction"`
	TransactionOutcome ExecutionOutcomeWithIdView   `json:"transaction_outcome"`
	ReceiptsOutcome    []ExecutionOutcomeWithIdView `json:"receipts_outcome"`
}

type TransactionView

type TransactionView struct {
	SignerId   AccountId    `json:"signer_id"`
	PublicKey  PublicKey    `json:"public_key"`
	Nonce      int          `json:"nonce"`
	ReceiverId AccountId    `json:"receiver_id"`
	Actions    []ActionView `json:"actions"` // TODO: ActionView
	Signature  Signature    `json:"signature"`
	Txid       CryptoHash   `json:"hash"`
}

type Transfer

type Transfer struct {
	Deposit big.Int
}

type ValidatorStakeStructVersion

type ValidatorStakeStructVersion []byte

func (*ValidatorStakeStructVersion) UnmarshalJSON

func (vs *ValidatorStakeStructVersion) UnmarshalJSON(p []byte) error

Jump to

Keyboard shortcuts

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