client_v1

package
v0.0.0-...-c576f33 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Blockchain is ICON.
	Blockchain string = "ICON"

	// MainnetNetwork is the value of the network
	// in MainnetNetworkIdentifier.
	MainnetNetwork string = "Mainnet"

	// TestnetNetwork is the value of the network
	// in TestnetNetworkIdentifier.
	TestnetNetwork string = "Testnet"

	ZiconNetwork string = "ZiconNet"

	// for develop
	DevelopNetwork string = "Devnet"

	ICXSymbol   = "ICX"
	ICXDecimals = 18

	GenesisBlockIndex          = int64(0)
	HistoricalBalanceSupported = false

	TreasuryAddress    = "hx1000000000000000000000000000000000000000"
	SystemScoreAddress = "cx0000000000000000000000000000000000000000"

	GenesisOpType     = "GENESIS"
	TransferOpType    = "TRANSFER"
	FeeOpType         = "FEE"
	BaseOpType        = "BASE"
	BurnOpType        = "BURN"
	WithdrawnType     = "WITHDRAWN"
	ICXTransferOpType = "ICXTRANSFER"
	ClaimOpType       = "CLAIM"
	IssueOpType       = "ISSUE"
	MessageOpType     = "MESSAGE"

	BaseDataType = "base"

	SuccessStatus = "SUCCESS"
	FailureStatus = "FAIL"
)

Variables

View Source
var (
	ICXCurrency = &types.Currency{
		Symbol:   ICXSymbol,
		Decimals: ICXDecimals,
	}

	OperationTypes = []string{
		GenesisOpType,
		TransferOpType,
		FeeOpType,
		BaseOpType,
		IssueOpType,
		BurnOpType,
		ICXTransferOpType,
		ClaimOpType,
		MessageOpType,
	}

	// OperationStatuses are all supported operation statuses.
	OperationStatuses = []*types.OperationStatus{
		{
			Status:     SuccessStatus,
			Successful: true,
		},
		{
			Status:     FailureStatus,
			Successful: false,
		},
	}

	MiddlewareVersion = "0.0.1"
	RosettaVersion    = "1.4.0"
	NodeVersion       = "1.8.0"
	StepPrice         = big.NewInt(12500000000)
	TransferStepCost  = big.NewInt(100000)
)

Functions

func GetOperations

func GetOperations(fa string, els []*EventLog, lastOpIndex int64) []*types.Operation

func GetUserStep

func GetUserStep(from string, stepDetails map[string]*common.HexInt) *big.Int

func HexIntAdd

func HexIntAdd(x *common.HexInt, y *common.HexInt) *big.Int

func MakeBaseOperations

func MakeBaseOperations() (*types.Operation, error)

func MapNetwork

func MapNetwork(n string) *common.HexInt64

func MarshalJSONMap

func MarshalJSONMap(i interface{}) (map[string]interface{}, error)

func NewHttpError

func NewHttpError(r *http.Response) error

func ParseBlock

func ParseBlock(raw map[string]interface{}) (*types.Block, error)

func ParseBlock01a

func ParseBlock01a(blk *Block01a) (*types.Block, error)

func ParseBlock03

func ParseBlock03(blk *Block03) (*types.Block, error)

func ParseGenesisBlock

func ParseGenesisBlock(blk *Block01a) (*types.Block, error)

func ParseGenesisOperationsV2

func ParseGenesisOperationsV2(tx GenesisTransaction) ([]*types.Operation, error)

func ParseGenesisTransaction

func ParseGenesisTransaction(txArray []json.RawMessage) ([]*types.Transaction, error)

func ParseOperationsV2

func ParseOperationsV2(transaction Transaction) ([]*types.Operation, error)

func ParseOperationsV3

func ParseOperationsV3(transaction Transaction) ([]*types.Operation, error)

func ParseTransactionV2

func ParseTransactionV2(transaction Transaction) (*types.Transaction, error)

func ParseTransactionV3

func ParseTransactionV3(transaction Transaction) (*types.Transaction, error)

func ParseTransactions

func ParseTransactions(txArray []json.RawMessage) ([]*types.Transaction, error)

func UnmarshalJSONMap

func UnmarshalJSONMap(m map[string]interface{}, i interface{}) error

Types

type BalanceRPCRequest

type BalanceRPCRequest struct {
	Address string `json:"address"`
	Filter  string `json:"filter"`
}

type BalanceWithBlockId

type BalanceWithBlockId struct {
	ID     common.HexBytes `json:"block_hash"`
	Height common.HexInt64 `json:"height"`
}

func (*BalanceWithBlockId) Hash

func (info *BalanceWithBlockId) Hash() string

func (*BalanceWithBlockId) Number

func (info *BalanceWithBlockId) Number() int64

type Block01a

type Block01a struct {
	ID                 common.HexBytes   `json:"block_hash"`
	Version            string            `json:"version"`
	Height             common.HexInt64   `json:"height"`
	Timestamp          common.HexInt64   `json:"time_stamp"`
	Proposer           common.Address    `json:"peer_id"`
	PrevID             common.HexBytes   `json:"prev_block_hash"`
	MerkleTreeRootHash common.HexBytes   `json:"merkle_tree_root_hash"`
	Signature          common.Signature  `json:"signature"`
	NextLeader         common.Address    `json:"next_leader"`
	Transactions       []json.RawMessage `json:"confirmed_transaction_list" `
}

func (*Block01a) GenesisMeta

func (b *Block01a) GenesisMeta() map[string]interface{}

func (*Block01a) Hash

func (b *Block01a) Hash() string

func (*Block01a) Meta

func (b *Block01a) Meta() map[string]interface{}

func (*Block01a) Number

func (b *Block01a) Number() int64

func (*Block01a) PrevHash

func (b *Block01a) PrevHash() string

func (*Block01a) Time

func (b *Block01a) Time() int64

func (*Block01a) TimestampMilli

func (b *Block01a) TimestampMilli() int64

type Block03

type Block03 struct {
	ID               common.HexBytes   `json:"hash"`
	Version          string            `json:"version"`
	Height           common.HexInt64   `json:"height"`
	Timestamp        common.HexInt64   `json:"timestamp"`
	Leader           common.Address    `json:"leader"`
	PrevID           common.HexBytes   `json:"prevHash"`
	TransactionsHash common.HexBytes   `json:"transactionsHash"`
	Signature        *common.Signature `json:"signature,omitempty"`
	NextLeader       common.Address    `json:"nextLeader"`
	Transactions     []json.RawMessage `json:"transactions"`
	StateHash        common.HexBytes   `json:"stateHash"`
	ReceiptsHash     common.HexBytes   `json:"receiptsHash"`
	RepsHash         common.HexBytes   `json:"repsHash"`
	NextRepsHash     common.HexBytes   `json:"nextRepsHash"`
	LeaderVotesHash  common.HexBytes   `json:"leaderVotesHash"`
	PrevVotesHash    common.HexBytes   `json:"prevVotesHash"`
	LogsBloom        common.HexBytes   `json:"logsBloom"`
}

func (*Block03) Hash

func (b *Block03) Hash() string

func (*Block03) Meta

func (b *Block03) Meta() map[string]interface{}

func (*Block03) Number

func (b *Block03) Number() int64

func (*Block03) PrevHash

func (b *Block03) PrevHash() string

func (*Block03) Time

func (b *Block03) Time() int64

func (*Block03) TimestampMilli

func (b *Block03) TimestampMilli() int64

type BlockRPCRequest

type BlockRPCRequest struct {
	Hash   string `json:"hash,omitempty"`
	Height string `json:"height,omitempty"`
}

type ClientV3

type ClientV3 struct {
	*JsonRpcClient
	DebugEndPoint string
}

func NewClientV3

func NewClientV3(endpoint string) *ClientV3

func (*ClientV3) EstimateStep

func (c *ClientV3) EstimateStep(req interface{}) (*Response, error)

func (*ClientV3) GetBalance

func (c *ClientV3) GetBalance(param *BalanceRPCRequest) (*types.AccountBalanceResponse, error)

func (*ClientV3) GetBlock

func (c *ClientV3) GetBlock(param *BlockRPCRequest) (*types.Block, error)

func (*ClientV3) GetBlockReceipts

func (c *ClientV3) GetBlockReceipts(param *BlockRPCRequest) ([]*TransactionResult, error)

func (*ClientV3) GetMainPReps

func (c *ClientV3) GetMainPReps() (*map[string]interface{}, error)

func (*ClientV3) GetPRep

func (c *ClientV3) GetPRep(prep string) (*map[string]interface{}, error)

func (*ClientV3) GetTotalSupply

func (c *ClientV3) GetTotalSupply() (*jsonrpc.HexInt, error)

func (*ClientV3) GetTransaction

func (c *ClientV3) GetTransaction(param *TransactionRPCRequest) (*types.Transaction, error)

func (*ClientV3) GetTransactionResult

func (c *ClientV3) GetTransactionResult(param *TransactionRPCRequest) (*TransactionResult, error)

func (*ClientV3) MakeBlockWithReceipts

func (c *ClientV3) MakeBlockWithReceipts(block *types.Block, trsArray []*TransactionResult) (*types.Block, error)

func (*ClientV3) MakeTransactionWithReceipt

func (c *ClientV3) MakeTransactionWithReceipt(tx *types.Transaction, txResult *TransactionResult) (*types.Transaction, error)

func (*ClientV3) SendTransaction

func (c *ClientV3) SendTransaction(req interface{}) error

type DebugAccount

type DebugAccount struct {
	Coin  coin  `json:"coin"`
	Stake stake `json:"stake"`
}

func (*DebugAccount) Balance

func (da *DebugAccount) Balance() string

type EventLog

type EventLog struct {
	Addr    string    `json:"scoreAddress"`
	Indexed []*string `json:"indexed"`
	Data    []*string `json:"data"`
}

type GenesisAccount

type GenesisAccount struct {
	Name    string         `json:"name"`
	Address common.Address `json:"address"`
	Balance *common.HexInt `json:"balance"`
}

func (*GenesisAccount) Addr

func (ga *GenesisAccount) Addr() string

func (*GenesisAccount) Balances

func (ga *GenesisAccount) Balances() string

type GenesisTransaction

type GenesisTransaction struct {
	Accounts []GenesisAccount `json:"accounts"`
	Message  string           `json:"message"`
}

type HttpError

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

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) Response

func (e *HttpError) Response() string

type JsonRpcClient

type JsonRpcClient struct {
	Endpoint     string
	CustomHeader map[string]string
	Pre          func(req *http.Request) error
	// contains filtered or unexported fields
}

func NewJsonRpcClient

func NewJsonRpcClient(hc *http.Client, endpoint string) *JsonRpcClient

func (*JsonRpcClient) Do

func (c *JsonRpcClient) Do(method string, reqPtr, respPtr interface{}) (jrResp *Response, err error)

func (*JsonRpcClient) DoURL

func (c *JsonRpcClient) DoURL(url string, method string, reqPtr, respPtr interface{}) (jrResp *Response, err error)

func (*JsonRpcClient) Raw

func (c *JsonRpcClient) Raw(reqB []byte) (resp *http.Response, err error)

type Response

type Response struct {
	Version string          `json:"jsonrpc"`
	Result  json.RawMessage `json:"result"`
	Error   *jsonrpc.Error  `json:"error,omitempty"`
	ID      interface{}     `json:"id"`
}

type Transaction

type Transaction struct {
	Version   common.HexUint16  `json:"version"`
	From      common.Address    `json:"from"`
	To        common.Address    `json:"to"`
	Value     *common.HexInt    `json:"value,omitempty"`
	StepLimit common.HexInt     `json:"stepLimit"`
	Timestamp common.HexInt64   `json:"timestamp"`
	NID       *common.HexInt64  `json:"nid"`
	Nonce     *common.HexInt    `json:"nonce,omitempty"`
	Signature *common.Signature `json:"signature,omitempty"`
	DataType  *string           `json:"dataType,omitempty"`
	Data      json.RawMessage   `json:"data,omitempty"`
	Fee       *common.HexInt    `json:"fee,omitempty"`
	TxHashV3  common.HexBytes   `json:"txHash,omitempty"`
	TxHashV2  common.HexBytes   `json:"tx_hash,omitempty"`
	Method    string            `json:"method,omitempty"`
}

func ParseV3JSON

func ParseV3JSON(js []byte) (*Transaction, error)

func (*Transaction) CalcHash

func (tx *Transaction) CalcHash() ([]byte, error)

func (*Transaction) FeeValue

func (tx *Transaction) FeeValue() string

func (*Transaction) FromAddr

func (tx *Transaction) FromAddr() string

func (*Transaction) GetDataType

func (tx *Transaction) GetDataType() string

func (*Transaction) MetaV2

func (tx *Transaction) MetaV2() map[string]interface{}

func (*Transaction) MetaV3

func (tx *Transaction) MetaV3() map[string]interface{}

func (*Transaction) StepValues

func (tx *Transaction) StepValues() string

func (*Transaction) ToAddr

func (tx *Transaction) ToAddr() string

func (*Transaction) ToJSON

func (tx *Transaction) ToJSON() (map[string]interface{}, error)

func (*Transaction) TxHash

func (tx *Transaction) TxHash() []byte

func (*Transaction) Values

func (tx *Transaction) Values() string

func (*Transaction) VerifySignature

func (tx *Transaction) VerifySignature() error

type TransactionRPCRequest

type TransactionRPCRequest struct {
	Hash string `json:"txHash"`
}

type TransactionResult

type TransactionResult struct {
	StatusFlag         string
	Status             json.RawMessage           `json:"status"`
	BlockHeight        *json.RawMessage          `json:"blockHeight"`
	BlockHash          *json.RawMessage          `json:"blockHash"`
	TxHash             *json.RawMessage          `json:"txHash"`
	TxIndex            *json.RawMessage          `json:"txIndex"`
	To                 *json.RawMessage          `json:"to"`
	ScoreAddress       *json.RawMessage          `json:"scoreAddress"`
	StepUsed           *common.HexInt            `json:"stepUsed"`
	CumulativeStepUsed *common.HexInt            `json:"cumulativeStepUsed"`
	StepPrice          *common.HexInt            `json:"stepPrice"`
	LogsBloom          *json.RawMessage          `json:"logsBloom"`
	EventLogs          []*EventLog               `json:"eventLogs"`
	Failure            *json.RawMessage          `json:"failure"`
	StepDetails        map[string]*common.HexInt `json:"stepUsedDetails"`
}

func ParseTransactionResult

func ParseTransactionResult(tx interface{}) (*TransactionResult, error)

func ParseTransactionResults

func ParseTransactionResults(trsRaws *[]interface{}) ([]*TransactionResult, error)

Jump to

Keyboard shortcuts

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