Documentation ¶
Index ¶
- Constants
- func AddUserGetResponce(t provider.T, hlfProxy HlfProxyService) (User, *Response)
- func AsBytes(args ...string) [][]byte
- func CheckAllowedBalanceEqual(t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, ...)
- func CheckBalanceEqual(t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, ...)
- func CheckBalanceEqualWithRetry(t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, ...)
- func CheckStatusCode(t provider.T, expectedResponseCode int, actualResponseCode int)
- func ConvertPemTox509certificate(bytes []byte) (*x509.Certificate, error)
- func ConvertPublicKeyToBase58(publicKey ed25519.PublicKey) string
- func EmitGetTxIDAndCheckBalance(t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, ...) string
- func FillStructFromBody(t provider.T, body []byte, tt any)
- func GeneratePrivateAndPublicKey() (ed25519.PrivateKey, ed25519.PublicKey, error)
- func GenerateUserPublicKeyBase58(t provider.T) string
- func GetAddressByPublicKey(publicKey ed25519.PublicKey) (string, error)
- func GetEmitPayload(t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, ...) string
- func GetEnv(key, defaultValue string) string
- func GetNonce() string
- func GetPrivateKeyFromBase58Check(secretKey string) (ed25519.PrivateKey, ed25519.PublicKey, error)
- func MakeJSONArrayFromNdJSON(body []byte) string
- func MultisigHex(methodName string, args []string, users ...User) ([]string, error)
- func MultisigHexWithNonce(methodName string, args []string, nonce string, users ...User) ([]string, error)
- func Sign(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, channel string, ...) ([]string, error)
- func SignExpand(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, channel string, ...) ([]string, error)
- func SignHex(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, methodName string, ...) ([]string, error)
- func SignHexWithNonce(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, methodName string, ...) ([]string, error)
- func SignWithNonce(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, channel string, ...) ([]string, error)
- func SwapFiatToCCCheckBalanceAndGetSwapDoneAndSwapBeginTxID(t provider.T, hlfProxy HlfProxyService, user User, amount string) (string, string)
- type HTTPClient
- type HlfProxyService
- func (p *HlfProxyService) GetPayloadInvoke(chaincodeID string, fcn string, args ...string) ([]byte, error)
- func (p *HlfProxyService) GetPayloadQuery(chaincodeID string, fcn string, args ...string) ([]byte, error)
- func (p *HlfProxyService) Invoke(chaincodeID string, fcn string, args ...string) (*Response, error)
- func (p *HlfProxyService) Query(chaincodeID string, fcn string, args ...string) (*Response, error)
- type Issuer
- type Options
- type Request
- type RequestPrx
- type Response
- type ResponseError
- type ResponseErrorPrx
- type ResponsePrx
- type User
Constants ¶
const ( // HlfProxyURL - domain and port for hlf proxy service, example http://localhost:9001 without '/' on the end the string HlfProxyURL = "HLF_PROXY_URL" // HlfProxyAuthToken - support Basic Auth with auth token HlfProxyAuthToken = "HLF_PROXY_AUTH_TOKEN" //nolint:gosec // FiatIssuerPrivateKey - issuer private key ed25519 in base58 check FiatIssuerPrivateKey = "FIAT_ISSUER_PRIVATE_KEY" // BatchTransactionTimeout - common time execution of following process // robot - defaultBatchLimits.batchTimeoutLimit // Time batch execute by robot BatchTransactionTimeout = 2 * time.Second // ObserverAPIURL - domain and port for observer service, example http://localhost:3335/api without '/' on the end the string ObserverAPIURL = "OBSERVER_API_URL" // CorrectNodeName Name of any node from stand CorrectNodeName = "CORRECT_NODE_NAME" // DefaultSwapHash - default swap hash DefaultSwapHash = "7d4e3eec80026719639ed4dba68916eb94c7a49a053e05c8f9578fe4e5a3d7ea" // #nosec G101 // DefaultSwapKey - default swap key DefaultSwapKey = "12345" // InvokeTimeout sets timeout for invoke method operations InvokeTimeout = 10 * time.Second // QueryTimeout sets timeout for query method operations QueryTimeout = 10 * time.Second // MoreNonceTTL sets timeout for nonce MoreNonceTTL = 11 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func AddUserGetResponce ¶
func AddUserGetResponce(t provider.T, hlfProxy HlfProxyService) (User, *Response)
AddUserGetResponce adds user and returns response
func CheckAllowedBalanceEqual ¶
func CheckAllowedBalanceEqual(t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, channel string, tokenUppercase string, amount string)
CheckAllowedBalanceEqual checks that allowed balance of userAddressBase58Check is equal to amount
func CheckBalanceEqual ¶
func CheckBalanceEqual(t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, channel string, amount string)
CheckBalanceEqual checks that balance of userAddressBase58Check is equal to amount
func CheckBalanceEqualWithRetry ¶
func CheckBalanceEqualWithRetry(t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, channel string, amount string, sleep time.Duration, retries int)
CheckBalanceEqualWithRetry checks that balance of userAddressBase58Check is equal to amount with retries
func CheckStatusCode ¶
CheckStatusCode checks that status code is equal to expected
func ConvertPemTox509certificate ¶
func ConvertPemTox509certificate(bytes []byte) (*x509.Certificate, error)
ConvertPemTox509certificate converts pem to x509 certificate
func ConvertPublicKeyToBase58 ¶
ConvertPublicKeyToBase58 - use publicKey with standard encoded type - Base58
func EmitGetTxIDAndCheckBalance ¶
func EmitGetTxIDAndCheckBalance( t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, issuer Issuer, channel string, chaincode string, amount string, ) string
EmitGetTxIDAndCheckBalance emits amount of tokens to userAddressBase58Check and checks that balance is equal to amount
func FillStructFromBody ¶
FillStructFromBody fills struct from body\
func GeneratePrivateAndPublicKey ¶
func GeneratePrivateAndPublicKey() (ed25519.PrivateKey, ed25519.PublicKey, error)
GeneratePrivateAndPublicKey - create new private and public key
func GenerateUserPublicKeyBase58 ¶
GenerateUserPublicKeyBase58 generates user public key base58
func GetAddressByPublicKey ¶
GetAddressByPublicKey - get address by encoded string in standard encoded for project is 'base58.Check'
func GetEmitPayload ¶
func GetEmitPayload( t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, issuer Issuer, amount string, ) string
GetEmitPayload emits amount of tokens to userAddressBase58Check and checks that balance is equal to amount
func GetPrivateKeyFromBase58Check ¶
GetPrivateKeyFromBase58Check - get private key type Ed25519 by string - Base58Check encoded private key
func MakeJSONArrayFromNdJSON ¶
MakeJSONArrayFromNdJSON converts NDJSON to JSON array
func MultisigHex ¶
MultisigHex - added multisign in HEX
func MultisigHexWithNonce ¶
func MultisigHexWithNonce(methodName string, args []string, nonce string, users ...User) ([]string, error)
MultisigHexWithNonce - added multisign in HEX with nonce
func Sign ¶
func Sign(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, channel string, chaincode string, methodName string, args []string) ([]string, error)
Sign - sign arguments before send to hlf. create message with certain order arguments expected by chaincode validation in foundation library
func SignExpand ¶
func SignExpand(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, channel string, chaincode string, methodName string, args []string, nonce string, externalRequestID string) ([]string, error)
SignExpand - sign arguments before send to hlf. create message with certain order arguments expected by chaincode validation in foundation library
func SignHex ¶
func SignHex(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, methodName string, args []string) ([]string, error)
SignHex - sign arguments in HEX before send to hlf. create message with certain order arguments expected by chaincode validation in foundation library
func SignHexWithNonce ¶
func SignHexWithNonce(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, methodName string, args []string, nonce string) ([]string, error)
SignHexWithNonce - sign arguments in HEX before send to hlf. create message with certain order arguments expected by chaincode validation in foundation library
func SignWithNonce ¶
func SignWithNonce(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, channel string, chaincode string, methodName string, args []string, nonce string) ([]string, error)
SignWithNonce - sign arguments before send to hlf. create message with certain order arguments expected by chaincode validation in foundation library
func SwapFiatToCCCheckBalanceAndGetSwapDoneAndSwapBeginTxID ¶
func SwapFiatToCCCheckBalanceAndGetSwapDoneAndSwapBeginTxID(t provider.T, hlfProxy HlfProxyService, user User, amount string) (string, string)
SwapFiatToCCCheckBalanceAndGetSwapDoneAndSwapBeginTxID swaps amount of tokens from fiat to cc channel
Types ¶
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient struct url - domain and port for observer service, example http://localhost:3335/api without '/' on the end the string. HTTPClient is used to send requests to observer service.
func NewHTTPClient ¶
func NewHTTPClient(url ...string) *HTTPClient
NewHTTPClient - create new instance of HTTPClient
func (*HTTPClient) PrepareURL ¶
func (o *HTTPClient) PrepareURL(t provider.T, apiPath string) string
PrepareURL - prepare url for request
type HlfProxyService ¶
type HlfProxyService struct {
// contains filtered or unexported fields
}
HlfProxyService struct url - domain and port for hlf proxy service, example http://localhost:9001 without '/' on the end the string authToken - support Basic Auth with auth token
func NewHlfProxyService ¶
func NewHlfProxyService(url string, authToken string) *HlfProxyService
NewHlfProxyService - create new instance of HlfProxyService
func (*HlfProxyService) GetPayloadInvoke ¶
func (p *HlfProxyService) GetPayloadInvoke(chaincodeID string, fcn string, args ...string) ([]byte, error)
GetPayloadInvoke - send invoke request to hlf through hlf proxy service
func (*HlfProxyService) GetPayloadQuery ¶
func (p *HlfProxyService) GetPayloadQuery(chaincodeID string, fcn string, args ...string) ([]byte, error)
GetPayloadQuery - send query request to hlf through hlf proxy service
type Issuer ¶
type Issuer struct { IssuerEd25519PrivateKey ed25519.PrivateKey IssuerEd25519PublicKey ed25519.PublicKey IssuerEd25519PublicKeyBase58 string }
Issuer struct
type Options ¶
type Options struct {
TargetEndpoints []string `json:"targetEndpoints"`
}
Options that can be used to specify target endpoints for the transaction invocation.
type Request ¶
type Request struct { Args [][]byte `json:"args"` ChaincodeID string `json:"chaincodeId"` Fcn string `json:"fcn"` }
Request struct for request to hlf proxy
type RequestPrx ¶
type RequestPrx struct { Args [][]byte `json:"args"` ChaincodeID string `json:"chaincodeId"` Fcn string `json:"fcn"` Opts *Options `json:"options,omitempty"` }
RequestPrx struct for request to hlf proxy
type Response ¶
type Response struct { BlockNumber int64 `json:"blockNumber,omitempty"` ChaincodeStatus int64 `json:"chaincodeStatus,omitempty"` Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` TransactionID string `json:"transactionId,omitempty"` TxValidationCode int64 `json:"txValidationCode,omitempty"` }
Response struct for response from hlf proxy
func EmitGetResponseAndCheckBalance ¶
func EmitGetResponseAndCheckBalance( t provider.T, hlfProxy HlfProxyService, userAddressBase58Check string, iss Issuer, channel string, chaincode string, amount string, ) *Response
EmitGetResponseAndCheckBalance emits amount of tokens to userAddressBase58Check and checks that balance is equal to amount
func TransferCheckBalanceAndGetRespose ¶
func TransferCheckBalanceAndGetRespose( t provider.T, hlfProxy HlfProxyService, userFrom User, userToAddress string, channel string, chaincode string, amount string, ) *Response
TransferCheckBalanceAndGetRespose transfers amount of tokens from userFrom to userToAddress and checks that balance of userToAddress is equal to amount
type ResponseError ¶
ResponseError struct for response error from hlf proxy
type ResponseErrorPrx ¶
ResponseErrorPrx struct for response error from hlf proxy
type ResponsePrx ¶
type ResponsePrx struct { BlockNumber int64 `json:"blockNumber,omitempty"` ChaincodeStatus int64 `json:"chaincodeStatus,omitempty"` Payload []byte `json:"payload,omitempty"` TransactionID string `json:"transactionId,omitempty"` TxValidationCode int64 `json:"txValidationCode,omitempty"` }
ResponsePrx struct for response from hlf proxy