neartx

package
v0.0.0-...-16c109c Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: CC0-1.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxGas         = 300_000_000_000_000
	ED25519KeyType = 0
)
View Source
const (
	CreateContractEnum = iota
	DeployContractEnum
	FunctionCallEnum
	TransferEnum
	StakeEnum
	AddKeyEnum
	DeleteKeyEnum
	DeleteAccountEnum
)

Variables

This section is empty.

Functions

func GetNonce

func GetNonce(rpcUrl, accountId string, pubKey ed25519.PublicKey) (uint64, []byte, error)

func SendTx

func SendTx(rpcUrl string, transaction []byte) ([]byte, error)

Types

type Action

type Action struct {
	Enum           borsh.Enum `borsh_enum:"true"`
	CreateAccount  CreateAccount
	DeployContract DeployContract
	FunctionCall   FunctionCall
	Transfer       Transfer
	Stake          Stake
	AddKey         AddKey
	DeleteKey      DeleteKey
	DeleteAccount  DeleteAccount
}

type AddKey

type AddKey struct{}

type CreateAccount

type CreateAccount struct{}

type DeleteAccount

type DeleteAccount struct{}

type DeleteKey

type DeleteKey struct{}

type DeployContract

type DeployContract struct{}

type FunctionCall

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

type KeyPairFunc

type KeyPairFunc func(signer string) (keyPairFunc NamedKeyPairFunc, err error)

type NamedKeyPairFunc

type NamedKeyPairFunc func() (signerName string, publicKey ed25519.PublicKey, privateKey ed25519.PrivateKey)

type NamedPubKeyFunc

type NamedPubKeyFunc func() (signerName string, publicKey ed25519.PublicKey)

type NearTransaction

type NearTransaction struct {
	ETX SignedTransaction
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction(signer, receiver string, signerKeyPair KeyPairFunc) *NearTransaction

NewTransaction creates a new NearTransaction sent by "signer" to "receiver". "signerKeyPair" returns the signer's keypair.

func (*NearTransaction) AddFunctionCall

func (tx *NearTransaction) AddFunctionCall(method string, encodedArgs []byte, gas uint64, deposit *big.Int) *NearTransaction

AddFunctionCall adds a function call to "method" with "encodedArgs" as argument. Only "method" is required to be not nil.

func (*NearTransaction) Error

func (tx *NearTransaction) Error() error

func (*NearTransaction) Send

func (tx *NearTransaction) Send(rpc RPCURL, nonceSource NonceFunc) ([]byte, error)

Send a NearTransaction. Signs it and sends it to rpc. nonceSource can be nil to be set to the rpc.

func (*NearTransaction) Sign

func (tx *NearTransaction) Sign(nonceSource NonceFunc) ([]byte, error)

Sign a NearTransaction with the keypair return from the NearTransaction() signerKeyPair.

type Network

type Network string

func (Network) FileSigner

func (network Network) FileSigner(signer string) (keypairFunc NamedKeyPairFunc, err error)

type NonceFunc

type NonceFunc func(signer NamedPubKeyFunc) (nonce uint64, blockHash []byte, err error)

type PublicKey

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

type RPCError

type RPCError struct {
	RPCError *struct {
		Name  string `json:"name"`
		Cause struct {
			Info map[string]interface{} `json:"info"`
			Name string                 `json:"name"`
		} `json:"cause"`
		Code    int64  `json:"code"`
		Message string `json:"message"`
		Data    struct {
			TxExecutionError map[string]interface{}
		} `json:"data"`
	} `json:"error"`
}

func (*RPCError) Error

func (err *RPCError) Error() string

type RPCURL

type RPCURL string

func (RPCURL) GetNonce

func (rpcUrl RPCURL) GetNonce(f NamedPubKeyFunc) (nonce uint64, blackHash []byte, err error)

func (RPCURL) SendTransaction

func (rpcUrl RPCURL) SendTransaction(tx []byte) ([]byte, error)

type Signature

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

type SignedTransaction

type SignedTransaction struct {
	Transaction Transaction
	Signature   Signature
}

type Signer

type Signer struct {
	AccountID  string `json:"account_id"`
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
	// contains filtered or unexported fields
}

func GetSigner

func GetSigner(name, network string) (*Signer, error)

func (*Signer) KeyPair

func (signer *Signer) KeyPair(signerReq string) (keypairFunc NamedKeyPairFunc, err error)

type Stake

type Stake struct{}

type Transaction

type Transaction struct {
	SignerID   string
	PublicKey  PublicKey
	Nonce      uint64
	ReceiverID string
	BlockHash  [32]byte
	Actions    []Action
}

type Transfer

type Transfer struct{}

Jump to

Keyboard shortcuts

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