@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 +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1944,6 +1944,7 @@ var getPositions = async (config, walletAddress) => {
|
|
|
1944
1944
|
// src/modules/markets.ts
|
|
1945
1945
|
var DEFAULT_API_BASE_URL = "https://partners.alphaarcade.com/api";
|
|
1946
1946
|
var DEFAULT_MARKET_CREATOR_ADDRESS = "5P5Y6HTWUNG2E3VXBQDZN3ENZD3JPAIR5PKT3LOYJAPAUKOLFD6KANYTRY";
|
|
1947
|
+
var toSeconds = (ts) => ts > 1e10 ? Math.floor(ts / 1e3) : ts;
|
|
1947
1948
|
var groupMultiChoiceMarkets = (flatMarkets) => {
|
|
1948
1949
|
const parentMap = /* @__PURE__ */ new Map();
|
|
1949
1950
|
const result = [];
|
|
@@ -2073,11 +2074,16 @@ var getMarketsFromApi = async (config) => {
|
|
|
2073
2074
|
throw new Error(`Alpha API error: ${response.status} ${response.statusText}`);
|
|
2074
2075
|
}
|
|
2075
2076
|
const data = await response.json();
|
|
2077
|
+
const normalizeApiMarket = (m) => ({
|
|
2078
|
+
...m,
|
|
2079
|
+
endTs: m.endTs ? toSeconds(m.endTs) : 0,
|
|
2080
|
+
source: "api"
|
|
2081
|
+
});
|
|
2076
2082
|
if (Array.isArray(data)) {
|
|
2077
|
-
allMarkets.push(...data.map(
|
|
2083
|
+
allMarkets.push(...data.map(normalizeApiMarket));
|
|
2078
2084
|
hasMore = false;
|
|
2079
2085
|
} else if (data.markets) {
|
|
2080
|
-
allMarkets.push(...data.markets.map(
|
|
2086
|
+
allMarkets.push(...data.markets.map(normalizeApiMarket));
|
|
2081
2087
|
lastEvaluatedKey = data.lastEvaluatedKey;
|
|
2082
2088
|
hasMore = !!lastEvaluatedKey;
|
|
2083
2089
|
} else {
|
|
@@ -2099,7 +2105,10 @@ var getMarketFromApi = async (config, marketId) => {
|
|
|
2099
2105
|
}
|
|
2100
2106
|
const data = await response.json();
|
|
2101
2107
|
const market = data.market ?? data ?? null;
|
|
2102
|
-
if (market)
|
|
2108
|
+
if (market) {
|
|
2109
|
+
market.source = "api";
|
|
2110
|
+
if (market.endTs) market.endTs = toSeconds(market.endTs);
|
|
2111
|
+
}
|
|
2103
2112
|
return market;
|
|
2104
2113
|
};
|
|
2105
2114
|
var getMarkets = async (config) => {
|