icon

package
v0.0.0-...-c85e2bb Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// NodeVersion is the version of goloop we are using.
	NodeVersion = "1.2.13"

	// Blockchain is ICON.
	Blockchain string = "ICON"

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

	// LisbonNetwork is the value of the network
	// in LisbonNetworkIdentifier.
	LisbonNetwork string = "Lisbon"

	// BerlinNetwork is the value of the network
	// in BerlinNetworkIdentifier.
	BerlinNetwork string = "Berlin"

	// LocalNetwork is the value of the network
	// in LocalNetworkIdentifier.
	LocalNetwork string = "Localnet"

	EndpointPrefix  = "api"
	EndpointVersion = "v3"
	EndpointAdmin   = "admin"
	EndpointRosetta = "rosetta"

	ICXSymbol   = "ICX"
	ICXDecimals = 18

	GenesisBlockIndex          = int64(0)
	HistoricalBalanceSupported = true
	IncludeMempoolCoins        = false

	TreasuryAddress    = "hx1000000000000000000000000000000000000000"
	SystemScoreAddress = "cx0000000000000000000000000000000000000000"

	GenesisOpType    = "GENESIS"
	TransferOpType   = "TRANSFER"
	FeeOpType        = "FEE"
	IssueOpType      = "ISSUE"
	BurnOpType       = "BURN"
	LostOpType       = "LOST"
	FSDepositOpType  = "FS_DEPOSIT"
	FSWithdrawOpType = "FS_WITHDRAW"
	FSFeeOpType      = "FS_FEE"
	StakeOpType      = "STAKE"
	UnstakeOpType    = "UNSTAKE"
	ClaimOpType      = "CLAIM"
	GhostOpType      = "GHOST"
	RewardOpType     = "REWARD"
	RegPRepOpType    = "REG_PREP"
	MessageOpType    = "MESSAGE"

	BaseOpType        = "BASE"
	WithdrawnType     = "WITHDRAWN"
	ICXTransferOpType = "ICXTRANSFER"
	DeployOpType      = "DEPLOY"
	CallOpType        = "CALL"
	DepositOpType     = "DEPOSIT"
	BugOpType         = "BUG"

	BaseDataType     = "base"
	TransferDataType = "transfer"
	MessageDataType  = "message"
	DeployDataType   = "deploy"
	CallDataType     = "call"
	DepositDataType  = "deposit"

	SuccessStatus = "SUCCESS"
	FailureStatus = "FAIL"

	GenesisTxHash = "0x0000000000000000000000000000000000000000000000000000000000000000"
)
View Source
const AddressStringLength = 42

Variables

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

	OperationTypes = []string{
		GenesisOpType,
		TransferOpType,
		FeeOpType,
		IssueOpType,
		BurnOpType,
		LostOpType,
		FSDepositOpType,
		FSWithdrawOpType,
		FSFeeOpType,
		StakeOpType,
		UnstakeOpType,
		ClaimOpType,
		GhostOpType,
		RewardOpType,
		RegPRepOpType,
		MessageOpType,
	}

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

Functions

func CheckAddress

func CheckAddress(as string) error

func GetOperations

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

func GetRpcRequest

func GetRpcRequest(method string, reqPtr interface{}, id int64) (*jsonrpc.Request, error)

func HandleBugTransaction

func HandleBugTransaction(transaction *types.Transaction, address string)

func IsContract

func IsContract(as string) bool

func MakeBaseOperations

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

func MapNetwork

func MapNetwork(n string) *common.HexInt

func MarshalJSONMap

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

func NewHttpError

func NewHttpError(r *http.Response) error

func ParseBlock

func ParseBlock(blk *Block) (*types.Block, error)

func ParseGenesisBlock

func ParseGenesisBlock(blk *Block) (*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 BalanceChange

type BalanceChange struct {
	TxHash  string       `json:"txHash"`
	TxIndex string       `json:"txIndex"`
	Ops     []*Operation `json:"ops"`
}

type BalanceRPCRequest

type BalanceRPCRequest struct {
	Address string `json:"address"`
	Height  string `json:"height,omitempty"`
}

type Block

type Block struct {
	BlockHash          common.HexBytes   `json:"block_hash"`
	Version            string            `json:"version"`
	Height             int64             `json:"height"`
	Timestamp          int64             `json:"time_stamp"`
	Proposer           common.Address    `json:"peer_id"`
	PrevBlockHash      common.HexBytes   `json:"prev_block_hash"`
	MerkleTreeRootHash common.HexBytes   `json:"merkle_tree_root_hash"`
	Signature          common.HexBytes   `json:"signature"`
	Transactions       []json.RawMessage `json:"confirmed_transaction_list"`
}

func (Block) GenesisMeta

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

func (Block) Hash

func (b Block) Hash() string

func (Block) Meta

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

func (Block) Number

func (b Block) Number() int64

func (Block) PrevHash

func (b Block) PrevHash() string

func (Block) TimestampInMillis

func (b Block) TimestampInMillis() int64

type BlockRPCRequest

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

type Client

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

Client is used to fetch blocks from ICON Node and to parser ICON block data into Rosetta types.

func NewClient

func NewClient(endpoint string) *Client

func (*Client) GetBlock

func (*Client) GetDefaultStepCost

func (ic *Client) GetDefaultStepCost() (*common.HexInt, error)

func (*Client) GetPeer

func (ic *Client) GetPeer() ([]*RosettaTypes.Peer, error)

func (*Client) GetTransaction

func (ic *Client) GetTransaction(params *RosettaTypes.TransactionIdentifier) (*RosettaTypes.Transaction, error)

func (*Client) SendTransaction

func (ic *Client) SendTransaction(tx Transaction) error

func (*Client) Status

type ClientAdmin

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

func NewClientAdmin

func NewClientAdmin(endpoint string) *ClientAdmin

type ClientV3

type ClientV3 struct {
	*JsonRpcClient
}

func NewClientV3

func NewClientV3(endpoint string) *ClientV3

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) Request

func (c *JsonRpcClient) Request(jrReq *jsonrpc.Request, respPtr interface{}) (*Response, error)

func (*JsonRpcClient) RequestBatch

func (c *JsonRpcClient) RequestBatch(jrReq []*jsonrpc.Request, respPtr []interface{}) ([]*Response, error)

type Operation

type Operation struct {
	OpType string        `json:"opType"`
	From   string        `json:"from"`
	To     string        `json:"to"`
	Amount common.HexInt `json:"amount"`
}

func (Operation) IntValue

func (op Operation) IntValue() string

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 RosettaTraceParam

type RosettaTraceParam struct {
	Tx     string `json:"tx,omitempty"`
	Block  string `json:"block,omitempty"`
	Height string `json:"height,omitempty"`
}

type RosettaTraceResponse

type RosettaTraceResponse struct {
	BlockHash      string           `json:"blockHash"`
	PrevBlockHash  string           `json:"prevBlockHash"`
	BlockHeight    common.HexInt64  `json:"blockHeight"`
	Timestamp      common.HexInt64  `json:"timestamp"`
	BalanceChanges []*BalanceChange `json:"balanceChanges"`
}

func (RosettaTraceResponse) Index

func (rt RosettaTraceResponse) Index() int64

func (RosettaTraceResponse) TimestampInMillis

func (rt RosettaTraceResponse) TimestampInMillis() int64

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.HexInt    `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