Table of Contents

Method ConnectAsync

Namespace
WhalesSecret.TradeScriptLib.API
Assembly
WhalesSecret.TradeScriptLib.dll

ConnectAsync(Uri, string, NewExternalDataHandlerAsync, ExternalDataErrorHandlerAsync?)

Connects to the external source of data as a client. This method can only be called once in the trade script's lifetime.

Task ConnectAsync(Uri uri, string issuerPublicKeyHex, IExternalApiV1.NewExternalDataHandlerAsync newDataHandler, IExternalApiV1.ExternalDataErrorHandlerAsync? errorHandler = null)

Parameters

uri Uri

HTTP(s) URI of the external data feed.

issuerPublicKeyHex string

Public key of the external data issuer in hex format. The public key is an EC point calculated from the private key and it is exported as a concatenation of binary representations of X and Y coordinates of the EC point. Therefore, the expected value is formed as hex(pubKey.X||pubKey.Y). The key is used for verification of the signature of the external data.

newDataHandler IExternalApiV1.NewExternalDataHandlerAsync

Callback method that is called when new data is received from the external data source.

errorHandler IExternalApiV1.ExternalDataErrorHandlerAsync

Callback method that is called when an error occurs while an attempt to get external data was made.

Returns

Task

A Task representing the asynchronous operation.

Exceptions

AlreadyExistsException

Thrown when the method is called more than once in the trade script's lifetime.

InvalidArgumentException

Thrown if uri or issuerPublicKeyHex or newDataHandler is null, or if uri is not Absolute, or if issuerPublicKeyHex is not a valid public key encoded in hex format.

See Also

ConnectAsync(Uri, string, TimeSpan?, NewExternalDataHandlerAsync, ExternalDataErrorHandlerAsync?)

Connects to the external source of data as a client. This method can only be called once in the trade script's lifetime.

Task ConnectAsync(Uri uri, string issuerPublicKeyHex, TimeSpan? downloadTimeout, IExternalApiV1.NewExternalDataHandlerAsync newDataHandler, IExternalApiV1.ExternalDataErrorHandlerAsync? errorHandler = null)

Parameters

uri Uri

HTTP(s) URI of the external data feed.

issuerPublicKeyHex string

Public key of the external data issuer in hex format. The public key is an EC point calculated from the private key and it is exported as a concatenation of binary representations of X and Y coordinates of the EC point. Therefore, the expected value is formed as hex(pubKey.X||pubKey.Y). The key is used for verification of the signature of the external data.

downloadTimeout TimeSpan?

Timeout for a single download operation, or null not to have a time limit for the download operation. This specifies how long does the client wait for the external data source to send the response before considering the attempt as failed.

newDataHandler IExternalApiV1.NewExternalDataHandlerAsync

Callback method that is called when new data is received from the external data source.

errorHandler IExternalApiV1.ExternalDataErrorHandlerAsync

Callback method that is called when an error occurs while an attempt to get external data was made.

Returns

Task

A Task representing the asynchronous operation.

Exceptions

AlreadyExistsException

Thrown when the method is called more than once in the trade script's lifetime.

InvalidArgumentException

Thrown if uri or issuerPublicKeyHex or newDataHandler is null, or if uri is not Absolute, or if issuerPublicKeyHex is not a valid public key encoded in hex format.

See Also