polkamarkets-js 3.1.7 → 3.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkamarkets-js",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -11,26 +11,18 @@ const ERC20Contract = require('./ERC20Contract');
11
11
 
12
12
  const realitioLib = require('@reality.eth/reality-eth-lib/formatters/question');
13
13
 
14
- const actions = {
15
- 0: 'Buy',
16
- 1: 'Sell',
17
- 2: 'Add Liquidity',
18
- 3: 'Remove Liquidity',
19
- 4: 'Claim Winnings',
20
- 5: 'Claim Liquidity',
21
- 6: 'Claim Fees',
22
- 7: 'Claim Voided',
23
- }
24
-
25
- /**
26
- * PredictionMarket Contract Object
27
- * @constructor PredictionMarketContract
28
- * @param {Web3} web3
29
- * @param {Integer} decimals
30
- * @param {Address} contractAddress
31
- */
32
-
33
14
  class PredictionMarketV2Contract extends IContract {
15
+ static ACTIONS = {
16
+ 0: 'Buy',
17
+ 1: 'Sell',
18
+ 2: 'Add Liquidity',
19
+ 3: 'Remove Liquidity',
20
+ 4: 'Claim Winnings',
21
+ 5: 'Claim Liquidity',
22
+ 6: 'Claim Fees',
23
+ 7: 'Claim Voided',
24
+ };
25
+
34
26
  constructor(params) {
35
27
  super({...params, abi: params.abi || prediction});
36
28
  this.contractName = 'predictionMarketV2';
@@ -411,7 +403,7 @@ class PredictionMarketV2Contract extends IContract {
411
403
  const decimals = marketDecimals[marketIds.indexOf(event.returnValues.marketId)];
412
404
 
413
405
  return {
414
- action: actions[Numbers.fromBigNumberToInteger(event.returnValues.action, 18)],
406
+ action: this.constructor.ACTIONS[Numbers.fromBigNumberToInteger(event.returnValues.action, 18)],
415
407
  marketId: Numbers.fromBigNumberToInteger(event.returnValues.marketId, 18),
416
408
  outcomeId: Numbers.fromBigNumberToInteger(event.returnValues.outcomeId, 18),
417
409
  shares: Numbers.fromDecimalsNumber(event.returnValues.shares, decimals),
@@ -278,13 +278,11 @@ class PredictionMarketV3Contract extends PredictionMarketV2Contract {
278
278
  marketsPrices = await this.querier.getMarketsPrices({ marketIds });
279
279
  }
280
280
 
281
- // fetching all markets decimals asynchrounously
282
- const marketDecimals = await this.getMarketsERC20Decimals({ marketIds });
283
-
284
281
  return marketIds.reduce((obj, marketId) => {
285
282
  const index = marketIds.indexOf(marketId);
286
283
  const marketData = marketsPrices[index];
287
- const decimals = marketDecimals[marketId];
284
+ // market prices decimals are always 18, don't depend on the erc20 decimals
285
+ const decimals = 18;
288
286
 
289
287
  return {
290
288
  ...obj,
@@ -350,7 +348,7 @@ class PredictionMarketV3Contract extends PredictionMarketV2Contract {
350
348
  const decimals = marketDecimals[event.returnValues.marketId];
351
349
 
352
350
  return {
353
- action: actions[Numbers.fromBigNumberToInteger(event.returnValues.action, 18)],
351
+ action: this.constructor.ACTIONS[Numbers.fromBigNumberToInteger(event.returnValues.action, 18)],
354
352
  marketId: Numbers.fromBigNumberToInteger(event.returnValues.marketId, 18),
355
353
  outcomeId: Numbers.fromBigNumberToInteger(event.returnValues.outcomeId, 18),
356
354
  shares: Numbers.fromDecimalsNumber(event.returnValues.shares, decimals),