mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2024-10-01 01:35:42 -04:00
add getMarketPrices call and tests
This commit is contained in:
parent
d33c3227e0
commit
ee9cbda667
@ -238,6 +238,8 @@ message GetCryptoCurrencyPaymentMethodsReply {
|
||||
service Price {
|
||||
rpc GetMarketPrice (MarketPriceRequest) returns (MarketPriceReply) {
|
||||
}
|
||||
rpc GetMarketPrices (MarketPricesRequest) returns (MarketPricesReply) {
|
||||
}
|
||||
}
|
||||
|
||||
message MarketPriceRequest {
|
||||
@ -248,6 +250,18 @@ message MarketPriceReply {
|
||||
double price = 1;
|
||||
}
|
||||
|
||||
message MarketPricesRequest {
|
||||
}
|
||||
|
||||
message MarketPricesReply {
|
||||
repeated MarketPriceInfo market_price = 1;
|
||||
}
|
||||
|
||||
message MarketPriceInfo {
|
||||
string currency_code = 1;
|
||||
double price = 2;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// GetTradeStatistics
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -371,7 +385,7 @@ message TradeInfo {
|
||||
bool is_withdrawn = 23;
|
||||
string contract_as_json = 24;
|
||||
ContractInfo contract = 25;
|
||||
|
||||
|
||||
string maker_deposit_tx_id = 100;
|
||||
string taker_deposit_tx_id = 101;
|
||||
}
|
||||
@ -389,7 +403,7 @@ message ContractInfo {
|
||||
string maker_payout_address_string = 10;
|
||||
string taker_payout_address_string = 11;
|
||||
uint64 lock_time = 12;
|
||||
|
||||
|
||||
string arbitrator_node_address = 100;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
// import haveno types
|
||||
import {HavenoDaemon} from "./HavenoDaemon";
|
||||
import {XmrBalanceInfo, OfferInfo, TradeInfo} from './protobuf/grpc_pb'; // TODO (woodser): better names; haveno_grpc_pb, haveno_pb
|
||||
import {XmrBalanceInfo, OfferInfo, TradeInfo, MarketPriceInfo} from './protobuf/grpc_pb'; // TODO (woodser): better names; haveno_grpc_pb, haveno_pb
|
||||
import {PaymentAccount, Offer} from './protobuf/pb_pb';
|
||||
|
||||
// import monero-javascript
|
||||
@ -51,11 +51,11 @@ const WALLET_SYNC_PERIOD = 5000;
|
||||
const MAX_TIME_PEER_NOTICE = 3000;
|
||||
const TEST_CRYPTO_ACCOUNTS = [ // TODO (woodser): test other cryptos, fiat
|
||||
{
|
||||
currencyCode: "eth",
|
||||
currencyCode: "ETH",
|
||||
address: "0xdBdAb835Acd6fC84cF5F9aDD3c0B5a1E25fbd99f"
|
||||
},
|
||||
{
|
||||
currencyCode: "btc",
|
||||
currencyCode: "BTC",
|
||||
address: "bcrt1q6j90vywv8x7eyevcnn2tn2wrlg3vsjlsvt46qz"
|
||||
}
|
||||
];
|
||||
@ -88,18 +88,35 @@ test("Can get the version", async () => {
|
||||
|
||||
test("Can get market prices", async () => {
|
||||
|
||||
// test crypto prices
|
||||
// get all market prices
|
||||
let prices: MarketPriceInfo[] = await alice.getPrices();
|
||||
expect(prices.length).toBeGreaterThan(1);
|
||||
for (let price of prices) {
|
||||
expect(price.getCurrencyCode().length).toBeGreaterThan(0);
|
||||
expect(price.getPrice()).toBeGreaterThanOrEqual(0);
|
||||
}
|
||||
|
||||
// get market prices of specific currencies
|
||||
for (let testAccount of TEST_CRYPTO_ACCOUNTS) {
|
||||
let price = await alice.getPrice(testAccount.currencyCode);
|
||||
console.log(testAccount.currencyCode + " price: " + price);
|
||||
expect(price).toBeGreaterThan(0);
|
||||
await GenUtils.waitFor(1000); // wait before next request // TODO (woodser): disable price throttle?
|
||||
}
|
||||
|
||||
// test fiat price
|
||||
let price = await alice.getPrice("USD");
|
||||
console.log("usd price: " + price);
|
||||
expect(price).toBeGreaterThan(0);
|
||||
// test that prices are reasonable
|
||||
let usd = await alice.getPrice("USD");
|
||||
expect(usd).toBeGreaterThan(50);
|
||||
expect(usd).toBeLessThan(5000);
|
||||
let doge = await alice.getPrice("DOGE");
|
||||
expect(doge).toBeGreaterThan(200)
|
||||
expect(doge).toBeLessThan(20000);
|
||||
let btc = await alice.getPrice("BTC");
|
||||
expect(btc).toBeGreaterThan(0.0004)
|
||||
expect(btc).toBeLessThan(0.4);
|
||||
|
||||
// test invalid currency
|
||||
await expect(async () => {await alice.getPrice("INVALID_CURRENCY")})
|
||||
.rejects
|
||||
.toThrow('Currency not found: INVALID_CURRENCY');
|
||||
});
|
||||
|
||||
test("Can get balances", async () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as grpcWeb from 'grpc-web';
|
||||
import {GetVersionClient, PriceClient, WalletsClient, OffersClient, PaymentAccountsClient, TradesClient} from './protobuf/GrpcServiceClientPb';
|
||||
import {GetVersionRequest, GetVersionReply, MarketPriceRequest, MarketPriceReply, GetBalancesRequest, GetBalancesReply, XmrBalanceInfo, GetOffersRequest, GetOffersReply, OfferInfo, GetPaymentAccountsRequest, GetPaymentAccountsReply, CreateCryptoCurrencyPaymentAccountRequest, CreateCryptoCurrencyPaymentAccountReply, CreateOfferRequest, CreateOfferReply, CancelOfferRequest, TakeOfferRequest, TakeOfferReply, TradeInfo, GetTradeRequest, GetTradeReply, GetNewDepositSubaddressRequest, GetNewDepositSubaddressReply, ConfirmPaymentStartedRequest, ConfirmPaymentReceivedRequest} from './protobuf/grpc_pb';
|
||||
import {GetVersionRequest, GetVersionReply, MarketPriceRequest, MarketPriceReply, MarketPricesRequest, MarketPricesReply, MarketPriceInfo, GetBalancesRequest, GetBalancesReply, XmrBalanceInfo, GetOffersRequest, GetOffersReply, OfferInfo, GetPaymentAccountsRequest, GetPaymentAccountsReply, CreateCryptoCurrencyPaymentAccountRequest, CreateCryptoCurrencyPaymentAccountReply, CreateOfferRequest, CreateOfferReply, CancelOfferRequest, TakeOfferRequest, TakeOfferReply, TradeInfo, GetTradeRequest, GetTradeReply, GetNewDepositSubaddressRequest, GetNewDepositSubaddressReply, ConfirmPaymentStartedRequest, ConfirmPaymentReceivedRequest} from './protobuf/grpc_pb';
|
||||
import {PaymentAccount, AvailabilityResult} from './protobuf/pb_pb';
|
||||
|
||||
/**
|
||||
@ -51,10 +51,10 @@ class HavenoDaemon {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current market price of the given currency code as a ratio, e.g. ETH/XMR.
|
||||
* Get the current market price per 1 XMR in the given currency.
|
||||
*
|
||||
* @param {string} currencyCode - currency code to get the price of
|
||||
* @return {number} the current market price of the given currency code as a ratio, e.g. XMR/ETH
|
||||
* @param {string} currencyCode - currency code (fiat or crypto) to get the price of
|
||||
* @return {number} the current market price per 1 XMR in the given currency
|
||||
*/
|
||||
async getPrice(currencyCode: string): Promise<number> {
|
||||
let that = this;
|
||||
@ -65,7 +65,22 @@ class HavenoDaemon {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current market prices of all the currencies.
|
||||
*
|
||||
* @return {MarketPrice[]} price per 1 XMR in all supported currencies (fiat & crypto)
|
||||
*/
|
||||
async getPrices(): Promise<MarketPriceInfo[]> {
|
||||
let that = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
that._priceClient.getMarketPrices(new MarketPricesRequest(), {password: that._password}, function(err: grpcWeb.RpcError, response: MarketPricesReply) {
|
||||
if (err) reject(err);
|
||||
else resolve(response.getMarketPriceList());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's balances.
|
||||
*
|
||||
@ -298,4 +313,4 @@ class HavenoDaemon {
|
||||
}
|
||||
}
|
||||
|
||||
export {HavenoDaemon};
|
||||
export {HavenoDaemon};
|
||||
|
@ -764,6 +764,49 @@ export class PriceClient {
|
||||
this.methodInfoGetMarketPrice);
|
||||
}
|
||||
|
||||
methodInfoGetMarketPrices = new grpcWeb.MethodDescriptor(
|
||||
'/io.bisq.protobuffer.Price/GetMarketPrices',
|
||||
grpcWeb.MethodType.UNARY,
|
||||
grpc_pb.MarketPricesRequest,
|
||||
grpc_pb.MarketPricesReply,
|
||||
(request: grpc_pb.MarketPricesRequest) => {
|
||||
return request.serializeBinary();
|
||||
},
|
||||
grpc_pb.MarketPricesReply.deserializeBinary
|
||||
);
|
||||
|
||||
getMarketPrices(
|
||||
request: grpc_pb.MarketPricesRequest,
|
||||
metadata: grpcWeb.Metadata | null): Promise<grpc_pb.MarketPricesReply>;
|
||||
|
||||
getMarketPrices(
|
||||
request: grpc_pb.MarketPricesRequest,
|
||||
metadata: grpcWeb.Metadata | null,
|
||||
callback: (err: grpcWeb.RpcError,
|
||||
response: grpc_pb.MarketPricesReply) => void): grpcWeb.ClientReadableStream<grpc_pb.MarketPricesReply>;
|
||||
|
||||
getMarketPrices(
|
||||
request: grpc_pb.MarketPricesRequest,
|
||||
metadata: grpcWeb.Metadata | null,
|
||||
callback?: (err: grpcWeb.RpcError,
|
||||
response: grpc_pb.MarketPricesReply) => void) {
|
||||
if (callback !== undefined) {
|
||||
return this.client_.rpcCall(
|
||||
this.hostname_ +
|
||||
'/io.bisq.protobuffer.Price/GetMarketPrices',
|
||||
request,
|
||||
metadata || {},
|
||||
this.methodInfoGetMarketPrices,
|
||||
callback);
|
||||
}
|
||||
return this.client_.unaryCall(
|
||||
this.hostname_ +
|
||||
'/io.bisq.protobuffer.Price/GetMarketPrices',
|
||||
request,
|
||||
metadata || {},
|
||||
this.methodInfoGetMarketPrices);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class GetTradeStatisticsClient {
|
||||
|
56
src/protobuf/grpc_pb.d.ts
vendored
56
src/protobuf/grpc_pb.d.ts
vendored
@ -727,6 +727,62 @@ export namespace MarketPriceReply {
|
||||
}
|
||||
}
|
||||
|
||||
export class MarketPricesRequest extends jspb.Message {
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): MarketPricesRequest.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: MarketPricesRequest): MarketPricesRequest.AsObject;
|
||||
static serializeBinaryToWriter(message: MarketPricesRequest, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): MarketPricesRequest;
|
||||
static deserializeBinaryFromReader(message: MarketPricesRequest, reader: jspb.BinaryReader): MarketPricesRequest;
|
||||
}
|
||||
|
||||
export namespace MarketPricesRequest {
|
||||
export type AsObject = {
|
||||
}
|
||||
}
|
||||
|
||||
export class MarketPricesReply extends jspb.Message {
|
||||
getMarketPriceList(): Array<MarketPriceInfo>;
|
||||
setMarketPriceList(value: Array<MarketPriceInfo>): MarketPricesReply;
|
||||
clearMarketPriceList(): MarketPricesReply;
|
||||
addMarketPrice(value?: MarketPriceInfo, index?: number): MarketPriceInfo;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): MarketPricesReply.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: MarketPricesReply): MarketPricesReply.AsObject;
|
||||
static serializeBinaryToWriter(message: MarketPricesReply, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): MarketPricesReply;
|
||||
static deserializeBinaryFromReader(message: MarketPricesReply, reader: jspb.BinaryReader): MarketPricesReply;
|
||||
}
|
||||
|
||||
export namespace MarketPricesReply {
|
||||
export type AsObject = {
|
||||
marketPriceList: Array<MarketPriceInfo.AsObject>,
|
||||
}
|
||||
}
|
||||
|
||||
export class MarketPriceInfo extends jspb.Message {
|
||||
getCurrencyCode(): string;
|
||||
setCurrencyCode(value: string): MarketPriceInfo;
|
||||
|
||||
getPrice(): number;
|
||||
setPrice(value: number): MarketPriceInfo;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): MarketPriceInfo.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: MarketPriceInfo): MarketPriceInfo.AsObject;
|
||||
static serializeBinaryToWriter(message: MarketPriceInfo, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): MarketPriceInfo;
|
||||
static deserializeBinaryFromReader(message: MarketPriceInfo, reader: jspb.BinaryReader): MarketPriceInfo;
|
||||
}
|
||||
|
||||
export namespace MarketPriceInfo {
|
||||
export type AsObject = {
|
||||
currencyCode: string,
|
||||
price: number,
|
||||
}
|
||||
}
|
||||
|
||||
export class GetTradeStatisticsRequest extends jspb.Message {
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): GetTradeStatisticsRequest.AsObject;
|
||||
|
@ -74,8 +74,11 @@ goog.exportSymbol('proto.io.bisq.protobuffer.KeepFundsReply', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.KeepFundsRequest', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.LockWalletReply', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.LockWalletRequest', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.MarketPriceInfo', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.MarketPriceReply', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.MarketPriceRequest', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.MarketPricesReply', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.MarketPricesRequest', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.OfferInfo', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.PaymentAccountPayloadInfo', null, global);
|
||||
goog.exportSymbol('proto.io.bisq.protobuffer.RegisterDisputeAgentReply', null, global);
|
||||
@ -774,6 +777,69 @@ if (goog.DEBUG && !COMPILED) {
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceReply.displayName = 'proto.io.bisq.protobuffer.MarketPriceReply';
|
||||
}
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesRequest = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.io.bisq.protobuffer.MarketPricesRequest, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
/**
|
||||
* @public
|
||||
* @override
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesRequest.displayName = 'proto.io.bisq.protobuffer.MarketPricesRequest';
|
||||
}
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, proto.io.bisq.protobuffer.MarketPricesReply.repeatedFields_, null);
|
||||
};
|
||||
goog.inherits(proto.io.bisq.protobuffer.MarketPricesReply, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
/**
|
||||
* @public
|
||||
* @override
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.displayName = 'proto.io.bisq.protobuffer.MarketPricesReply';
|
||||
}
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.io.bisq.protobuffer.MarketPriceInfo, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
/**
|
||||
* @public
|
||||
* @override
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.displayName = 'proto.io.bisq.protobuffer.MarketPriceInfo';
|
||||
}
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
@ -7270,6 +7336,427 @@ proto.io.bisq.protobuffer.MarketPriceReply.prototype.setPrice = function(value)
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* Optional fields that are not set will be set to undefined.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
|
||||
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
|
||||
* JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesRequest.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.io.bisq.protobuffer.MarketPricesRequest.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
|
||||
* the JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPricesRequest} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesRequest.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPricesRequest}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesRequest.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.io.bisq.protobuffer.MarketPricesRequest;
|
||||
return proto.io.bisq.protobuffer.MarketPricesRequest.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPricesRequest} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPricesRequest}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesRequest.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesRequest.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
proto.io.bisq.protobuffer.MarketPricesRequest.serializeBinaryToWriter(this, writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the given message to binary data (in protobuf wire
|
||||
* format), writing to the given BinaryWriter.
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPricesRequest} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesRequest.serializeBinaryToWriter = function(message, writer) {
|
||||
var f = undefined;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List of repeated fields within this message type.
|
||||
* @private {!Array<number>}
|
||||
* @const
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.repeatedFields_ = [1];
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* Optional fields that are not set will be set to undefined.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
|
||||
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
|
||||
* JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.io.bisq.protobuffer.MarketPricesReply.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
|
||||
* the JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPricesReply} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
marketPriceList: jspb.Message.toObjectList(msg.getMarketPriceList(),
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.toObject, includeInstance)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPricesReply}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.io.bisq.protobuffer.MarketPricesReply;
|
||||
return proto.io.bisq.protobuffer.MarketPricesReply.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPricesReply} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPricesReply}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = new proto.io.bisq.protobuffer.MarketPriceInfo;
|
||||
reader.readMessage(value,proto.io.bisq.protobuffer.MarketPriceInfo.deserializeBinaryFromReader);
|
||||
msg.addMarketPrice(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.serializeBinaryToWriter(this, writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the given message to binary data (in protobuf wire
|
||||
* format), writing to the given BinaryWriter.
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPricesReply} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.serializeBinaryToWriter = function(message, writer) {
|
||||
var f = undefined;
|
||||
f = message.getMarketPriceList();
|
||||
if (f.length > 0) {
|
||||
writer.writeRepeatedMessage(
|
||||
1,
|
||||
f,
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* repeated MarketPriceInfo market_price = 1;
|
||||
* @return {!Array<!proto.io.bisq.protobuffer.MarketPriceInfo>}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.prototype.getMarketPriceList = function() {
|
||||
return /** @type{!Array<!proto.io.bisq.protobuffer.MarketPriceInfo>} */ (
|
||||
jspb.Message.getRepeatedWrapperField(this, proto.io.bisq.protobuffer.MarketPriceInfo, 1));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {!Array<!proto.io.bisq.protobuffer.MarketPriceInfo>} value
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPricesReply} returns this
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.prototype.setMarketPriceList = function(value) {
|
||||
return jspb.Message.setRepeatedWrapperField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPriceInfo=} opt_value
|
||||
* @param {number=} opt_index
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPriceInfo}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.prototype.addMarketPrice = function(opt_value, opt_index) {
|
||||
return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.io.bisq.protobuffer.MarketPriceInfo, opt_index);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Clears the list making it empty but non-null.
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPricesReply} returns this
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPricesReply.prototype.clearMarketPriceList = function() {
|
||||
return this.setMarketPriceList([]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* Optional fields that are not set will be set to undefined.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
|
||||
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
|
||||
* JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.io.bisq.protobuffer.MarketPriceInfo.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
|
||||
* the JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPriceInfo} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
currencyCode: jspb.Message.getFieldWithDefault(msg, 1, ""),
|
||||
price: jspb.Message.getFloatingPointFieldWithDefault(msg, 2, 0.0)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPriceInfo}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.io.bisq.protobuffer.MarketPriceInfo;
|
||||
return proto.io.bisq.protobuffer.MarketPriceInfo.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPriceInfo} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPriceInfo}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setCurrencyCode(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {number} */ (reader.readDouble());
|
||||
msg.setPrice(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.serializeBinaryToWriter(this, writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the given message to binary data (in protobuf wire
|
||||
* format), writing to the given BinaryWriter.
|
||||
* @param {!proto.io.bisq.protobuffer.MarketPriceInfo} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.serializeBinaryToWriter = function(message, writer) {
|
||||
var f = undefined;
|
||||
f = message.getCurrencyCode();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getPrice();
|
||||
if (f !== 0.0) {
|
||||
writer.writeDouble(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string currency_code = 1;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.prototype.getCurrencyCode = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPriceInfo} returns this
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.prototype.setCurrencyCode = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional double price = 2;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.prototype.getPrice = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 2, 0.0));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
* @return {!proto.io.bisq.protobuffer.MarketPriceInfo} returns this
|
||||
*/
|
||||
proto.io.bisq.protobuffer.MarketPriceInfo.prototype.setPrice = function(value) {
|
||||
return jspb.Message.setProto3FloatField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto.
|
||||
|
Loading…
Reference in New Issue
Block a user