sdk

package
v3.11.4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: LGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPubKey

func CheckPubKey(k string) bool

CheckPubKey check whether a string is a valid public key. Since it is not easy to check it fully, only check length here

func GetSignAlgoByEnum

func GetSignAlgoByEnum(enum rpcpb.Signature_Algorithm) crypto.Algorithm

GetSignAlgoByEnum ...

func GetSignAlgoByName

func GetSignAlgoByName(name string) crypto.Algorithm

GetSignAlgoByName ...

func GetSignatureOfTx

func GetSignatureOfTx(t *rpcpb.TransactionRequest, kp *account.KeyPair, withSign bool) *rpcpb.Signature

GetSignatureOfTx ...

func LoadProtoStructFromJSONFile

func LoadProtoStructFromJSONFile(fileName string, pb proto.Message) error

LoadProtoStructFromJSONFile ...

func MarshalTextString

func MarshalTextString(pb proto.Message) string

MarshalTextString ...

func NewAction

func NewAction(contract string, name string, data string) *rpcpb.Action

NewAction ...

func ParsePrivKey added in v3.8.1

func ParsePrivKey(rawKey string) []byte

func SaveProtoStructToJSONFile

func SaveProtoStructToJSONFile(pb proto.Message, fileName string) error

SaveProtoStructToJSONFile ...

func VerifySigForTx

func VerifySigForTx(t *rpcpb.TransactionRequest, sig *rpcpb.Signature, withSign bool) bool

VerifySigForTx ...

func VerifySignature

func VerifySignature(tx *rpcpb.TransactionRequest) error

VerifySignature verify signature of a signed tx

Types

type AccountInfo added in v3.7.0

type AccountInfo struct {
	Name     string                  `json:"name"`
	Keypairs map[string]*KeyPairInfo `json:"keypairs"`
}

AccountInfo ...

func LoadAccountFrom added in v3.7.0

func LoadAccountFrom(fileName string) (*AccountInfo, error)

func NewAccountInfo added in v3.7.0

func NewAccountInfo() *AccountInfo

NewAccountInfo ...

func (*AccountInfo) Decrypt added in v3.7.0

func (a *AccountInfo) Decrypt(password []byte) error

func (*AccountInfo) Encrypt added in v3.7.0

func (a *AccountInfo) Encrypt(password []byte) error

func (*AccountInfo) GetKeyPair added in v3.7.0

func (a *AccountInfo) GetKeyPair(perm string) (*account.KeyPair, error)

func (*AccountInfo) IsEncrypted added in v3.7.0

func (a *AccountInfo) IsEncrypted() bool

func (*AccountInfo) SaveTo added in v3.7.0

func (a *AccountInfo) SaveTo(fileName string) error

type FileAccountStore added in v3.7.0

type FileAccountStore struct {
	AccountDir string
}

func NewFileAccountStore added in v3.7.0

func NewFileAccountStore(accountDir string) *FileAccountStore

func (*FileAccountStore) DeleteAccount added in v3.7.0

func (s *FileAccountStore) DeleteAccount(name string) error

func (*FileAccountStore) ListAccounts added in v3.7.0

func (s *FileAccountStore) ListAccounts() ([]*AccountInfo, error)

func (*FileAccountStore) LoadAccount added in v3.7.0

func (s *FileAccountStore) LoadAccount(name string) (*AccountInfo, error)

func (*FileAccountStore) SaveAccount added in v3.7.0

func (s *FileAccountStore) SaveAccount(a *AccountInfo) error

type IOSTDevSDK

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

IOSTDevSDK ...

func NewIOSTDevSDK

func NewIOSTDevSDK() *IOSTDevSDK

NewIOSTDevSDK creatimg an SDK with reasonable params

func (*IOSTDevSDK) AddAccountWithPerm added in v3.7.0

func (s *IOSTDevSDK) AddAccountWithPerm(name string, kp *account.KeyPair, perm string)

func (*IOSTDevSDK) CloseConn

func (s *IOSTDevSDK) CloseConn()

CloseConn ...

func (*IOSTDevSDK) Connect

func (s *IOSTDevSDK) Connect() (err error)

Connect ...

func (*IOSTDevSDK) Connected

func (s *IOSTDevSDK) Connected() bool

Connected checks if is connected to grpc server.

func (*IOSTDevSDK) CreateNewAccount

func (s *IOSTDevSDK) CreateNewAccount(newID string, ownerKey string, activeKey string, initialGasPledge int64, initialRAM int64, initialCoins int64) (string, error)

CreateNewAccount ... return txHash

func (*IOSTDevSDK) CreateNewAccountActions

func (s *IOSTDevSDK) CreateNewAccountActions(newID string, ownerKey string, activeKey string, initialGasPledge int64, initialRAM int64, initialCoins int64) ([]*rpcpb.Action, error)

CreateNewAccountActions makes actions for creating new account.

func (*IOSTDevSDK) CreateTxFromActions

func (s *IOSTDevSDK) CreateTxFromActions(actions []*rpcpb.Action) (*rpcpb.TransactionRequest, error)

CreateTxFromActions ...

func (*IOSTDevSDK) CurrentAccount added in v3.7.0

func (s *IOSTDevSDK) CurrentAccount() string

func (*IOSTDevSDK) ExecTransaction

func (s *IOSTDevSDK) ExecTransaction(signedTx *rpcpb.TransactionRequest) (*rpcpb.TxReceipt, error)

ExecTransaction send raw transaction to server

func (*IOSTDevSDK) GetAccountInfo

func (s *IOSTDevSDK) GetAccountInfo(id string) (*rpcpb.Account, error)

GetAccountInfo return account info

func (*IOSTDevSDK) GetBatchContractStorage

GetBatchContractStorage ...

func (*IOSTDevSDK) GetBlockByHash

func (s *IOSTDevSDK) GetBlockByHash(hash string, complete bool) (*rpcpb.BlockResponse, error)

GetBlockByHash ...

func (*IOSTDevSDK) GetBlockByNum

func (s *IOSTDevSDK) GetBlockByNum(num int64, complete bool) (*rpcpb.BlockResponse, error)

GetBlockByNum ...

func (*IOSTDevSDK) GetChainInfo

func (s *IOSTDevSDK) GetChainInfo() (*rpcpb.ChainInfoResponse, error)

GetChainInfo ...

func (*IOSTDevSDK) GetContractStorage

GetContractStorage ...

func (*IOSTDevSDK) GetNodeInfo

func (s *IOSTDevSDK) GetNodeInfo() (*rpcpb.NodeInfoResponse, error)

GetNodeInfo ...

func (*IOSTDevSDK) GetProducerVoteInfo

GetProducerVoteInfo ...

func (*IOSTDevSDK) GetRAMInfo

func (s *IOSTDevSDK) GetRAMInfo() (*rpcpb.RAMInfoResponse, error)

GetRAMInfo ...

func (*IOSTDevSDK) GetTokenBalance

func (s *IOSTDevSDK) GetTokenBalance(account string, token string) (*rpcpb.GetTokenBalanceResponse, error)

GetTokenBalance return token balance

func (*IOSTDevSDK) GetTokenInfo

func (s *IOSTDevSDK) GetTokenInfo(token string) (*rpcpb.TokenInfo, error)

GetTokenInfo ...

func (*IOSTDevSDK) GetTxByHash

func (s *IOSTDevSDK) GetTxByHash(hash string) (*rpcpb.TransactionResponse, error)

GetTxByHash ...

func (*IOSTDevSDK) GetTxReceiptByTxHash

func (s *IOSTDevSDK) GetTxReceiptByTxHash(txHashStr string) (*rpcpb.TxReceipt, error)

GetTxReceiptByTxHash ...

func (*IOSTDevSDK) PledgeForGasAndRAM

func (s *IOSTDevSDK) PledgeForGasAndRAM(gasPledged int64, ram int64) error

PledgeForGasAndRAM ...

func (*IOSTDevSDK) PublishContract

func (s *IOSTDevSDK) PublishContract(codePath string, abiPath string, conID string, update bool, updateID string) (*rpcpb.TransactionRequest, string, error)

PublishContract converts contract js code to transaction. If 'send', also send it to chain.

func (*IOSTDevSDK) PublishContractActions

func (s *IOSTDevSDK) PublishContractActions(codePath string, abiPath string, conID string, update bool, updateID string) ([]*rpcpb.Action, error)

PublishContractActions makes actions for publishing contract.

func (*IOSTDevSDK) SendTransaction

func (s *IOSTDevSDK) SendTransaction(signedTx *rpcpb.TransactionRequest) (string, error)

SendTransaction send raw transaction to server

func (*IOSTDevSDK) SendTx

func (s *IOSTDevSDK) SendTx(tx *rpcpb.TransactionRequest) (string, error)

SendTx send transaction and check result if sdk.checkResult is set

func (*IOSTDevSDK) SendTxFromActions

func (s *IOSTDevSDK) SendTxFromActions(actions []*rpcpb.Action) (txHash string, err error)

SendTxFromActions send transaction and check result if sdk.checkResult is set

func (*IOSTDevSDK) SetAccount

func (s *IOSTDevSDK) SetAccount(name string, kp *account.KeyPair)

func (*IOSTDevSDK) SetChainID

func (s *IOSTDevSDK) SetChainID(chainID uint32)

SetChainID sets chainID.

func (*IOSTDevSDK) SetCheckResult

func (s *IOSTDevSDK) SetCheckResult(checkResult bool, checkResultDelay float32, checkResultMaxRetry int32)

SetCheckResult ...

func (*IOSTDevSDK) SetServer

func (s *IOSTDevSDK) SetServer(server string)

SetServer ...

func (*IOSTDevSDK) SetTxInfo

func (s *IOSTDevSDK) SetTxInfo(gasLimit float64, gasRatio float64, expiration int64, delaySecond int64, amountLimit []*rpcpb.AmountLimit)

SetTxInfo ...

func (*IOSTDevSDK) SetUseLongestChain

func (s *IOSTDevSDK) SetUseLongestChain(useLongestChain bool)

SetUseLongestChain ...

func (*IOSTDevSDK) SetVerbose

func (s *IOSTDevSDK) SetVerbose(verbose bool)

SetVerbose ...

func (*IOSTDevSDK) SignTx

SignTx ...

func (*IOSTDevSDK) TryTx

func (*IOSTDevSDK) UpdateAccountKeysActions added in v3.7.0

func (s *IOSTDevSDK) UpdateAccountKeysActions(account string, ownerKey string, activeKey string) ([]*rpcpb.Action, error)

func (*IOSTDevSDK) UseAccount added in v3.7.0

func (s *IOSTDevSDK) UseAccount(name string)

func (*IOSTDevSDK) UseAccountAndPerm added in v3.7.0

func (s *IOSTDevSDK) UseAccountAndPerm(name string, perm string)

type KeyPairInfo added in v3.7.0

type KeyPairInfo struct {
	RawKey        string `json:"raw_key,omitempty"`
	KeyType       string `json:"key_type"`
	PubKey        string `json:"public_key"`
	EncryptMethod string `json:"encrypt_method,omitempty"`
	Salt          string `json:"salt,omitempty"`
	EncryptedKey  string `json:"encrypted_key,omitempty"`
	Mac           string `json:"mac,omitempty"`
}

KeyPairInfo ...

func NewKeyPairInfo added in v3.7.0

func NewKeyPairInfo(rawKey string, keyType string) (*KeyPairInfo, error)

NewKeyPairInfo ...

func (*KeyPairInfo) Decrypt added in v3.7.0

func (k *KeyPairInfo) Decrypt(password []byte) error

func (*KeyPairInfo) Encrypt added in v3.7.0

func (k *KeyPairInfo) Encrypt(password []byte) error

func (*KeyPairInfo) IsEncrypted added in v3.7.0

func (k *KeyPairInfo) IsEncrypted() bool

func (*KeyPairInfo) ToKeyPair added in v3.7.0

func (k *KeyPairInfo) ToKeyPair() (*account.KeyPair, error)

Jump to

Keyboard shortcuts

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