@usherlabs/cex-broker 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -289986,7 +289986,9 @@ var log = new Logger({
289986
289986
  // src/helpers/index.ts
289987
289987
  function authenticateRequest(call, whitelistIps) {
289988
289988
  const clientIp = call.getPeer().split(":")[0];
289989
- if (!clientIp || !whitelistIps.includes(clientIp)) {
289989
+ if (whitelistIps.includes("*")) {
289990
+ return true;
289991
+ } else if (!clientIp || !whitelistIps.includes(clientIp)) {
289990
289992
  log.warn(`Blocked access from unauthorized IP: ${clientIp || "unknown"}`);
289991
289993
  return false;
289992
289994
  }
@@ -290158,7 +290160,8 @@ var Action = {
290158
290160
  CancelOrder: 5,
290159
290161
  FetchBalance: 6,
290160
290162
  FetchBalances: 7,
290161
- FetchDepositAddresses: 8
290163
+ FetchDepositAddresses: 8,
290164
+ FetchTicker: 9
290162
290165
  };
290163
290166
 
290164
290167
  // src/proto/cex_broker/SubscriptionType.ts
@@ -290234,7 +290237,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290234
290237
  if (deposit) {
290235
290238
  log.info(`Amount ${value.amount} at ${value.transactionHash} . Paid to ${value.recipientAddress}`);
290236
290239
  return callback(null, {
290237
- result: useVerity ? broker.last_proof : JSON.stringify({ ...deposit })
290240
+ proof: broker.last_proof || "",
290241
+ result: JSON.stringify({ ...deposit })
290238
290242
  });
290239
290243
  }
290240
290244
  callback({
@@ -290275,7 +290279,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290275
290279
  });
290276
290280
  if (depositAddresses) {
290277
290281
  return callback(null, {
290278
- result: useVerity ? broker.last_proof : JSON.stringify({ ...depositAddresses })
290282
+ proof: broker.last_proof || "",
290283
+ result: JSON.stringify({ ...depositAddresses })
290279
290284
  });
290280
290285
  }
290281
290286
  callback({
@@ -290325,7 +290330,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290325
290330
  const transaction = await broker.withdraw(symbol, Number(transferValue.amount), transferValue.recipientAddress, undefined, { network: transferValue.chain });
290326
290331
  log.info(`Transfer Transfer: ${JSON.stringify(transaction)}`);
290327
290332
  callback(null, {
290328
- result: useVerity ? broker.last_proof : JSON.stringify({ ...transaction })
290333
+ proof: broker.last_proof || "",
290334
+ result: JSON.stringify({ ...transaction })
290329
290335
  });
290330
290336
  } catch (error) {
290331
290337
  log.error({ error });
@@ -290445,7 +290451,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290445
290451
  });
290446
290452
  const currencyBalance = balance[symbol];
290447
290453
  callback(null, {
290448
- result: useVerity ? broker.last_proof : JSON.stringify({
290454
+ proof: broker.last_proof || "",
290455
+ result: JSON.stringify({
290449
290456
  balance: currencyBalance || 0,
290450
290457
  currency: symbol
290451
290458
  })
@@ -290464,7 +290471,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290464
290471
  ...call.request.payload ?? {}
290465
290472
  });
290466
290473
  callback(null, {
290467
- result: useVerity ? broker.last_proof : JSON.stringify(balance)
290474
+ proof: broker.last_proof || "",
290475
+ result: JSON.stringify(balance)
290468
290476
  });
290469
290477
  } catch (error) {
290470
290478
  log.error(`Error fetching balance from ${cex3}:`, error);
@@ -290474,6 +290482,21 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290474
290482
  }, null);
290475
290483
  }
290476
290484
  break;
290485
+ case Action.FetchTicker:
290486
+ try {
290487
+ const ticker = await broker.fetchTicker(symbol);
290488
+ callback(null, {
290489
+ proof: broker.last_proof || "",
290490
+ result: JSON.stringify(ticker)
290491
+ });
290492
+ } catch (error) {
290493
+ log.error(`Error fetching ticker from ${cex3}:`, error);
290494
+ callback({
290495
+ code: grpc.status.INTERNAL,
290496
+ message: `Failed to fetch ticker from ${cex3}`
290497
+ }, null);
290498
+ }
290499
+ break;
290477
290500
  default:
290478
290501
  return callback({
290479
290502
  code: grpc.status.INVALID_ARGUMENT,
@@ -290482,7 +290505,6 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290482
290505
  }
290483
290506
  },
290484
290507
  Subscribe: async (call) => {
290485
- const request = call.request;
290486
290508
  if (!authenticateRequest(call, whitelistIps)) {
290487
290509
  call.emit("error", {
290488
290510
  code: grpc.status.PERMISSION_DENIED,
@@ -290493,12 +290515,12 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290493
290515
  const metadata = call.metadata;
290494
290516
  let broker = null;
290495
290517
  try {
290496
- const request2 = call.request;
290497
- const { cex: cex3, symbol, type: type2, options } = request2;
290518
+ const request = call.request;
290519
+ const { cex: cex3, symbol, type: type2, options } = request;
290498
290520
  const subscriptionType = type2 !== undefined ? type2 : SubscriptionType.ORDERBOOK;
290499
290521
  log.info(`Request - Subscribe: ${JSON.stringify({
290500
- cex: request2.cex,
290501
- symbol: request2.symbol,
290522
+ cex: request.cex,
290523
+ symbol: request.symbol,
290502
290524
  type: subscriptionType
290503
290525
  })}`);
290504
290526
  if (!cex3 || !symbol) {
package/dist/index.js CHANGED
@@ -285033,7 +285033,9 @@ var log = new Logger({
285033
285033
  // src/helpers/index.ts
285034
285034
  function authenticateRequest(call, whitelistIps) {
285035
285035
  const clientIp = call.getPeer().split(":")[0];
285036
- if (!clientIp || !whitelistIps.includes(clientIp)) {
285036
+ if (whitelistIps.includes("*")) {
285037
+ return true;
285038
+ } else if (!clientIp || !whitelistIps.includes(clientIp)) {
285037
285039
  log.warn(`Blocked access from unauthorized IP: ${clientIp || "unknown"}`);
285038
285040
  return false;
285039
285041
  }
@@ -285205,7 +285207,8 @@ var Action = {
285205
285207
  CancelOrder: 5,
285206
285208
  FetchBalance: 6,
285207
285209
  FetchBalances: 7,
285208
- FetchDepositAddresses: 8
285210
+ FetchDepositAddresses: 8,
285211
+ FetchTicker: 9
285209
285212
  };
285210
285213
 
285211
285214
  // src/proto/cex_broker/SubscriptionType.ts
@@ -285281,7 +285284,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285281
285284
  if (deposit) {
285282
285285
  log.info(`Amount ${value.amount} at ${value.transactionHash} . Paid to ${value.recipientAddress}`);
285283
285286
  return callback(null, {
285284
- result: useVerity ? broker.last_proof : JSON.stringify({ ...deposit })
285287
+ proof: broker.last_proof || "",
285288
+ result: JSON.stringify({ ...deposit })
285285
285289
  });
285286
285290
  }
285287
285291
  callback({
@@ -285322,7 +285326,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285322
285326
  });
285323
285327
  if (depositAddresses) {
285324
285328
  return callback(null, {
285325
- result: useVerity ? broker.last_proof : JSON.stringify({ ...depositAddresses })
285329
+ proof: broker.last_proof || "",
285330
+ result: JSON.stringify({ ...depositAddresses })
285326
285331
  });
285327
285332
  }
285328
285333
  callback({
@@ -285372,7 +285377,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285372
285377
  const transaction = await broker.withdraw(symbol, Number(transferValue.amount), transferValue.recipientAddress, undefined, { network: transferValue.chain });
285373
285378
  log.info(`Transfer Transfer: ${JSON.stringify(transaction)}`);
285374
285379
  callback(null, {
285375
- result: useVerity ? broker.last_proof : JSON.stringify({ ...transaction })
285380
+ proof: broker.last_proof || "",
285381
+ result: JSON.stringify({ ...transaction })
285376
285382
  });
285377
285383
  } catch (error) {
285378
285384
  log.error({ error });
@@ -285492,7 +285498,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285492
285498
  });
285493
285499
  const currencyBalance = balance[symbol];
285494
285500
  callback(null, {
285495
- result: useVerity ? broker.last_proof : JSON.stringify({
285501
+ proof: broker.last_proof || "",
285502
+ result: JSON.stringify({
285496
285503
  balance: currencyBalance || 0,
285497
285504
  currency: symbol
285498
285505
  })
@@ -285511,7 +285518,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285511
285518
  ...call.request.payload ?? {}
285512
285519
  });
285513
285520
  callback(null, {
285514
- result: useVerity ? broker.last_proof : JSON.stringify(balance)
285521
+ proof: broker.last_proof || "",
285522
+ result: JSON.stringify(balance)
285515
285523
  });
285516
285524
  } catch (error) {
285517
285525
  log.error(`Error fetching balance from ${cex3}:`, error);
@@ -285521,6 +285529,21 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285521
285529
  }, null);
285522
285530
  }
285523
285531
  break;
285532
+ case Action.FetchTicker:
285533
+ try {
285534
+ const ticker = await broker.fetchTicker(symbol);
285535
+ callback(null, {
285536
+ proof: broker.last_proof || "",
285537
+ result: JSON.stringify(ticker)
285538
+ });
285539
+ } catch (error) {
285540
+ log.error(`Error fetching ticker from ${cex3}:`, error);
285541
+ callback({
285542
+ code: grpc.status.INTERNAL,
285543
+ message: `Failed to fetch ticker from ${cex3}`
285544
+ }, null);
285545
+ }
285546
+ break;
285524
285547
  default:
285525
285548
  return callback({
285526
285549
  code: grpc.status.INVALID_ARGUMENT,
@@ -285529,7 +285552,6 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285529
285552
  }
285530
285553
  },
285531
285554
  Subscribe: async (call) => {
285532
- const request = call.request;
285533
285555
  if (!authenticateRequest(call, whitelistIps)) {
285534
285556
  call.emit("error", {
285535
285557
  code: grpc.status.PERMISSION_DENIED,
@@ -285540,12 +285562,12 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285540
285562
  const metadata = call.metadata;
285541
285563
  let broker = null;
285542
285564
  try {
285543
- const request2 = call.request;
285544
- const { cex: cex3, symbol, type: type2, options } = request2;
285565
+ const request = call.request;
285566
+ const { cex: cex3, symbol, type: type2, options } = request;
285545
285567
  const subscriptionType = type2 !== undefined ? type2 : SubscriptionType.ORDERBOOK;
285546
285568
  log.info(`Request - Subscribe: ${JSON.stringify({
285547
- cex: request2.cex,
285548
- symbol: request2.symbol,
285569
+ cex: request.cex,
285570
+ symbol: request.symbol,
285549
285571
  type: subscriptionType
285550
285572
  })}`);
285551
285573
  if (!cex3 || !symbol) {
@@ -286119,4 +286141,4 @@ export {
286119
286141
  CEXBroker as default
286120
286142
  };
286121
286143
 
286122
- //# debugId=653E3F4FDCC17C0364756E2164756E21
286144
+ //# debugId=DEA73F64725EF87564756E2164756E21