polkamarkets-js 3.1.6 → 3.1.8
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
|
@@ -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:
|
|
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),
|
|
@@ -494,12 +486,12 @@ class PredictionMarketV2Contract extends IContract {
|
|
|
494
486
|
* @return {Integer} decimals
|
|
495
487
|
*/
|
|
496
488
|
async getMarketDecimals({marketId}) {
|
|
497
|
-
if (this.defaultDecimals) {
|
|
498
|
-
return this.defaultDecimals;
|
|
499
|
-
}
|
|
500
489
|
if (this.marketDecimals && this.marketDecimals[marketId]) {
|
|
501
490
|
return this.marketDecimals[marketId];
|
|
502
491
|
}
|
|
492
|
+
if (this.defaultDecimals) {
|
|
493
|
+
return this.defaultDecimals;
|
|
494
|
+
}
|
|
503
495
|
|
|
504
496
|
const marketAltData = await this.params.contract.getContract().methods.getMarketAltData(marketId).call();
|
|
505
497
|
const contractAddress = marketAltData[3];
|
|
@@ -350,7 +350,7 @@ class PredictionMarketV3Contract extends PredictionMarketV2Contract {
|
|
|
350
350
|
const decimals = marketDecimals[event.returnValues.marketId];
|
|
351
351
|
|
|
352
352
|
return {
|
|
353
|
-
action:
|
|
353
|
+
action: this.constructor.ACTIONS[Numbers.fromBigNumberToInteger(event.returnValues.action, 18)],
|
|
354
354
|
marketId: Numbers.fromBigNumberToInteger(event.returnValues.marketId, 18),
|
|
355
355
|
outcomeId: Numbers.fromBigNumberToInteger(event.returnValues.outcomeId, 18),
|
|
356
356
|
shares: Numbers.fromDecimalsNumber(event.returnValues.shares, decimals),
|