@bulletxyz/bullet-sdk 0.19.0-rc.0 → 0.20.0-rc.0

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.
@@ -6797,16 +6797,14 @@ var Schemas = {
6797
6797
  var ResponseSchemas = {
6798
6798
  DummyValue: StateResponseSchemas.StateValue(Schemas.DummyValue),
6799
6799
  Order: StateResponseSchemas.StateMapElement(OrderId, Schemas.Order),
6800
- UserAccount: createBaseResponse(
6801
- z.object({ user_accounts: z.array(Schemas.UserAccount) })
6800
+ UserAccounts: createBaseResponse(
6801
+ z.object({
6802
+ user_accounts: createJsonMap(Base58Address, Schemas.UserAccount)
6803
+ })
6802
6804
  ),
6803
6805
  Pricing: StateResponseSchemas.StateValue(Schemas.Pricing),
6804
6806
  UsdcPnlPool: StateResponseSchemas.StateValue(Schemas.UsdcPnlPool),
6805
6807
  UsdcInsuranceFund: StateResponseSchemas.StateValue(Schemas.UsdcInsuranceFund),
6806
- // BorrowLendMarket: StateResponseSchemas.StateMapElement(
6807
- // AssetId,
6808
- // Schemas.BorrowLendMarket,
6809
- // ),
6810
6808
  PerpMarket: StateResponseSchemas.StateMapElement(AssetId, Schemas.PerpMarket),
6811
6809
  OrderbookL2: createBaseResponse(
6812
6810
  z.object({
@@ -6814,10 +6812,12 @@ var ResponseSchemas = {
6814
6812
  })
6815
6813
  ),
6816
6814
  BorrowLendMarkets: createBaseResponse(
6817
- z.object({ markets: z.array(Schemas.BorrowLendMarket) })
6815
+ z.object({
6816
+ markets: createJsonMap(AssetId, Schemas.BorrowLendMarket)
6817
+ })
6818
6818
  ),
6819
6819
  PerpMarkets: createBaseResponse(
6820
- z.object({ markets: z.array(Schemas.PerpMarket) })
6820
+ z.object({ markets: createJsonMap(AssetId, Schemas.PerpMarket) })
6821
6821
  ),
6822
6822
  MarginConfig: StateResponseSchemas.StateValue(Schemas.MarginConfig),
6823
6823
  AccountAddresses: createBaseResponse(
@@ -7063,8 +7063,12 @@ var WebSocketManager = class {
7063
7063
  }
7064
7064
  async connect() {
7065
7065
  if (this.socket?.readyState === WebSocket.OPEN) return;
7066
- this.socket = new WebSocket(this.url);
7066
+ if (this.socket) {
7067
+ this.socket.close();
7068
+ this.socket = null;
7069
+ }
7067
7070
  return new Promise((resolve, reject) => {
7071
+ this.socket = new WebSocket(this.url);
7068
7072
  const timeout = setTimeout(() => {
7069
7073
  reject(new Error("Connection timeout"));
7070
7074
  this.socket?.close();
@@ -7241,7 +7245,7 @@ var ExchangeConnection = class extends BaseConnection {
7241
7245
  const response = await this.fetchApiResource(path, {
7242
7246
  addresses: addresses.join(",")
7243
7247
  });
7244
- const parsed = ResponseSchemas.UserAccount.parse(response);
7248
+ const parsed = ResponseSchemas.UserAccounts.parse(response);
7245
7249
  return parsed.data.user_accounts;
7246
7250
  }
7247
7251
  async getPricing() {
@@ -7268,7 +7272,7 @@ var ExchangeConnection = class extends BaseConnection {
7268
7272
  )}`;
7269
7273
  const response = await this.fetchApiResource(path);
7270
7274
  const parsed = ResponseSchemas.BorrowLendMarkets.parse(response);
7271
- return new Map(asset_ids.map((id, i) => [id, parsed.data.markets[i]]));
7275
+ return parsed.data.markets;
7272
7276
  }
7273
7277
  async getPerpMarkets(asset_ids) {
7274
7278
  const path = `/modules/exchange/perp-markets?asset_ids=${asset_ids.join(
@@ -7276,7 +7280,7 @@ var ExchangeConnection = class extends BaseConnection {
7276
7280
  )}`;
7277
7281
  const response = await this.fetchApiResource(path);
7278
7282
  const parsed = ResponseSchemas.PerpMarkets.parse(response);
7279
- return new Map(asset_ids.map((id, i) => [id, parsed.data.markets[i]]));
7283
+ return parsed.data.markets;
7280
7284
  }
7281
7285
  async getMarginConfig() {
7282
7286
  const path = "/modules/exchange/state/margin";
@@ -8949,8 +8953,8 @@ var Client = class _Client {
8949
8953
  return await this.connection.getTokenBalance(this.wallet.address, tokenId);
8950
8954
  }
8951
8955
  async getUserAccount() {
8952
- const ua = await this.exchange.getUserAccounts([this.wallet.address]);
8953
- return ua[0];
8956
+ const userAccounts = await this.exchange.getUserAccounts([this.wallet.address]);
8957
+ return userAccounts.get(this.wallet.address);
8954
8958
  }
8955
8959
  async submitTransaction(runtimeCall) {
8956
8960
  const result = await this.queue.add(async () => {