common

package
v0.0.0-...-0c944f3 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProxyHost          = "https://testnet-gateway.multiversx.com"
	Hrp                = "erd"
	MainnetId          = "1"
	SignMessagePrepend = "\x17Elrond Signed Message:\n"
	TickerMainnet      = "eGLD"
	TickerTestnet      = "XeGLD"

	TxHashSignVersion = 2
	TxHashSignOptions = 1
)
View Source
const (
	ErrOpenDevice                        = "couldn't open device"
	ErrGetAppVersion                     = "couldn't get app version"
	ErrGetConfig                         = "couldn't get configuration"
	ErrSetAddress                        = "couldn't set account and address index"
	ErrGetAddress                        = "couldn't get address"
	ErrGetNetworkConfig                  = "couldn't get network config"
	ErrGetBalanceAndNonce                = "couldn't get address balance and nonce"
	ErrEmptyAddress                      = "empty address"
	ErrInvalidAddress                    = "invalid receiver address"
	ErrInvalidAmount                     = "invalid eGLD amount"
	ErrSigningTx                         = "signing error"
	ErrSendingTx                         = "error sending tx"
	ErrInvalidBalanceString              = "invalid balance string"
	ErrInvalidHRP                        = "invalid bech32 hrp"
	ErrGetAddressShard                   = "getAddressShard error"
	ErrGetAccountAndAddressIndexFromUser = "invalid account or address index provided by user"
	ErrSigningMsg                        = "signing error"
)

Variables

View Source
var Status = [...]string{"Disabled", "Enabled"}
View Source
var TestSkBytes = []byte{0xb5, 0xe3, 0xcf, 0xb4, 0x42, 0xb0, 0xac, 0xad, 0xf5, 0xf5, 0xd1, 0xed, 0x1f, 0x7a, 0xc7, 0xb6,
	0xff, 0xc3, 0x28, 0xab, 0x29, 0x7b, 0xa0, 0xeb, 0x0e, 0x5c, 0xe7, 0x33, 0x8d, 0xe5, 0x49, 0x5e}

For testing the ESDT tokens whitelisting, one can use the following sk. For this secret key, you have to update the public key LEDGER_SIGNATURE_PUBLIC_KEY in ledger-elrond/src/provide_ESDT_info.h The public key specific to this secret key is:

static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = {
    0x04, 0x0d, 0x04, 0x9d, 0xd5, 0x3d, 0x97, 0x7d, 0x21, 0x92, 0xed, 0xeb, 0xba, 0xac, 0x71,
    0x39, 0x20, 0xda, 0xd2, 0x95, 0x59, 0x9a, 0x09, 0xf0, 0x8c, 0xe6, 0x25, 0x33, 0x37, 0x99,
    0x37, 0x5f, 0xc2, 0x81, 0xda, 0xf0, 0x24, 0x09, 0x66, 0x01, 0x34, 0xd2, 0x98, 0x8c, 0x4f,
    0xd3, 0x52, 0x6e, 0xde, 0x39, 0x4f, 0xa0, 0xe5, 0xdc, 0x3d, 0x3f, 0xb7, 0x30, 0xeb, 0x53,
    0xab, 0x35, 0xa6, 0x57, 0x5c};

Functions

func BroadcastTransaction

func BroadcastTransaction(tx Transaction) error

BroadcastTransaction broadcasts the transaction in the network

func GetAccountAndAddressIndexFromUser

func GetAccountAndAddressIndexFromUser() (uint32, uint32, error)

GetAccountAndAddressIndexFromUser retrieves the account and address index from user

func GetAddressShard

func GetAddressShard(bech32Address string, noOfShards uint32) (uint32, error)

GetAddressShard returns the assigned shard of an address

func GetDeviceInfo

func GetDeviceInfo(nanos *ledger.NanoS) error

GetDeviceInfo retrieves various information from Ledger

func GetSenderInfo

func GetSenderInfo(address string) (*big.Int, uint64, error)

GetSenderInfo returns the balance and nonce of an address

func GetTxDataFromUser

func GetTxDataFromUser(contractData uint8, denomination *big.Float, ticker string) (string, *big.Int, string, error)

GetTxDataFromUser retrieves tx fields from user

func SignTransaction

func SignTransaction(tx *Transaction, nanos *ledger.NanoS) error

SignTransaction sends the tx to Ledger for user confirmation and signing

func SignTransactionHash

func SignTransactionHash(tx *Transaction, nanos *ledger.NanoS) error

SignTransactionHash sends the tx to Ledger for user confirmation and signing

func WaitInputAndExit

func WaitInputAndExit()

Types

type GetAccountResponse

type GetAccountResponse struct {
	Data struct {
		Account struct {
			Address string `json:"address"`
			Nonce   uint64 `json:"nonce"`
			Balance string `json:"balance"`
		} `json:"account"`
	} `json:"data"`
}

type NetworkConfig

type NetworkConfig struct {
	Data struct {
		Config struct {
			ChainID                  string `json:"erd_chain_id"`
			Denomination             int    `json:"erd_denomination"`
			GasPerDataByte           uint64 `json:"erd_gas_per_data_byte"`
			LatestTagSoftwareVersion string `json:"erd_latest_tag_software_version"`
			MetaConsensusGroupSize   uint32 `json:"erd_meta_consensus_group_size"`
			MinGasLimit              uint64 `json:"erd_min_gas_limit"`
			MinGasPrice              uint64 `json:"erd_min_gas_price"`
			MinTransactionVersion    uint32 `json:"erd_min_transaction_version"`
			NumMetachainNodes        uint32 `json:"erd_num_metachain_nodes"`
			NumNodesInShard          uint32 `json:"erd_num_nodes_in_shard"`
			NumShardsWithoutMeta     uint32 `json:"erd_num_shards_without_meta"`
			RoundDuration            uint32 `json:"erd_round_duration"`
			ShardConsensusGroupSize  uint32 `json:"erd_shard_consensus_group_size"`
			StartTime                uint32 `json:"erd_start_time"`
		} `json:"config"`
	} `json:"data"`
}

func GetNetworkConfig

func GetNetworkConfig() (*NetworkConfig, error)

GetNetworkConfig reads the network config from the proxy and returns a networkConfig object

type Transaction

type Transaction struct {
	Nonce            uint64 `json:"nonce"`
	Value            string `json:"value"`
	RcvAddr          string `json:"receiver"`
	SndAddr          string `json:"sender"`
	SenderUsername   []byte `json:"senderUsername,omitempty"`
	ReceiverUsername []byte `json:"receiverUsername,omitempty"`
	GasPrice         uint64 `json:"gasPrice,omitempty"`
	GasLimit         uint64 `json:"gasLimit,omitempty"`
	Data             []byte `json:"data,omitempty"`
	Signature        string `json:"signature,omitempty"`
	ChainID          string `json:"chainID"`
	Version          uint32 `json:"version"`
	Options          uint32 `json:"options,omitempty"`
}

Jump to

Keyboard shortcuts

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