@alpha-arcade/sdk 0.2.3 → 0.2.4

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.
package/dist/index.cjs CHANGED
@@ -1969,6 +1969,7 @@ var getPositions = async (config, walletAddress) => {
1969
1969
  // src/modules/markets.ts
1970
1970
  var DEFAULT_API_BASE_URL = "https://partners.alphaarcade.com/api";
1971
1971
  var DEFAULT_MARKET_CREATOR_ADDRESS = "5P5Y6HTWUNG2E3VXBQDZN3ENZD3JPAIR5PKT3LOYJAPAUKOLFD6KANYTRY";
1972
+ var toSeconds = (ts) => ts > 1e10 ? Math.floor(ts / 1e3) : ts;
1972
1973
  var groupMultiChoiceMarkets = (flatMarkets) => {
1973
1974
  const parentMap = /* @__PURE__ */ new Map();
1974
1975
  const result = [];
@@ -2098,11 +2099,16 @@ var getMarketsFromApi = async (config) => {
2098
2099
  throw new Error(`Alpha API error: ${response.status} ${response.statusText}`);
2099
2100
  }
2100
2101
  const data = await response.json();
2102
+ const normalizeApiMarket = (m) => ({
2103
+ ...m,
2104
+ endTs: m.endTs ? toSeconds(m.endTs) : 0,
2105
+ source: "api"
2106
+ });
2101
2107
  if (Array.isArray(data)) {
2102
- allMarkets.push(...data.map((m) => ({ ...m, source: "api" })));
2108
+ allMarkets.push(...data.map(normalizeApiMarket));
2103
2109
  hasMore = false;
2104
2110
  } else if (data.markets) {
2105
- allMarkets.push(...data.markets.map((m) => ({ ...m, source: "api" })));
2111
+ allMarkets.push(...data.markets.map(normalizeApiMarket));
2106
2112
  lastEvaluatedKey = data.lastEvaluatedKey;
2107
2113
  hasMore = !!lastEvaluatedKey;
2108
2114
  } else {
@@ -2124,7 +2130,10 @@ var getMarketFromApi = async (config, marketId) => {
2124
2130
  }
2125
2131
  const data = await response.json();
2126
2132
  const market = data.market ?? data ?? null;
2127
- if (market) market.source = "api";
2133
+ if (market) {
2134
+ market.source = "api";
2135
+ if (market.endTs) market.endTs = toSeconds(market.endTs);
2136
+ }
2128
2137
  return market;
2129
2138
  };
2130
2139
  var getMarkets = async (config) => {