@azuro-org/toolkit 0.1.8 → 3.0.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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type Dictionaries } from '@azuro-org/dictionaries';
|
|
2
1
|
type Outcome<T> = T & {
|
|
3
2
|
conditionId: string;
|
|
4
3
|
outcomeId: string;
|
|
@@ -21,7 +20,6 @@ type Props = {
|
|
|
21
20
|
outcomeId: string;
|
|
22
21
|
}[];
|
|
23
22
|
}[];
|
|
24
|
-
dictionaries: Dictionaries;
|
|
25
23
|
};
|
|
26
24
|
export default function aggregateOutcomesByMarkets<T extends {}>(props: Props): FinalMarket<T>[];
|
|
27
25
|
export {};
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {getMarketKey,getMarketName,
|
|
1
|
+
import {getMarketKey,getMarketName,getSelectionName,dictionaries}from'@azuro-org/dictionaries';/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -35,17 +35,17 @@ function __rest(s, e) {
|
|
|
35
35
|
}
|
|
36
36
|
return t;
|
|
37
37
|
}function aggregateOutcomesByMarkets(props) {
|
|
38
|
-
var lpAddress = props.lpAddress, conditions = props.conditions
|
|
38
|
+
var lpAddress = props.lpAddress, conditions = props.conditions;
|
|
39
39
|
var marketsMap = {};
|
|
40
40
|
conditions.forEach(function (_a) {
|
|
41
41
|
var conditionId = _a.conditionId, outcomes = _a.outcomes, coreAddress = _a.coreAddress;
|
|
42
42
|
outcomes.forEach(function (_a) {
|
|
43
43
|
var outcomeId = _a.outcomeId, rest = __rest(_a, ["outcomeId"]);
|
|
44
44
|
// we are using the same key format that was discussed earlier
|
|
45
|
-
var marketKey = getMarketKey(outcomeId
|
|
45
|
+
var marketKey = getMarketKey(outcomeId);
|
|
46
46
|
// we are obtaining the human-readable names of each market and the corresponding outcome selections
|
|
47
|
-
var marketName = getMarketName(outcomeId
|
|
48
|
-
var selectionName =
|
|
47
|
+
var marketName = getMarketName({ outcomeId: outcomeId });
|
|
48
|
+
var selectionName = getSelectionName({ outcomeId: outcomeId });
|
|
49
49
|
var outcome = __assign({ conditionId: conditionId, outcomeId: outcomeId, lpAddress: lpAddress, coreAddress: coreAddress, selectionName: selectionName }, rest);
|
|
50
50
|
if (!marketsMap[marketKey]) {
|
|
51
51
|
marketsMap[marketKey] = {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type Dictionaries } from '@azuro-org/dictionaries';
|
|
2
1
|
type Outcome<T> = T & {
|
|
3
2
|
conditionId: string;
|
|
4
3
|
outcomeId: string;
|
|
@@ -21,7 +20,6 @@ type Props = {
|
|
|
21
20
|
outcomeId: string;
|
|
22
21
|
}[];
|
|
23
22
|
}[];
|
|
24
|
-
dictionaries: Dictionaries;
|
|
25
23
|
};
|
|
26
24
|
export default function aggregateOutcomesByMarkets<T extends {}>(props: Props): FinalMarket<T>[];
|
|
27
25
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -35,17 +35,17 @@ function __rest(s, e) {
|
|
|
35
35
|
}
|
|
36
36
|
return t;
|
|
37
37
|
}function aggregateOutcomesByMarkets(props) {
|
|
38
|
-
var lpAddress = props.lpAddress, conditions = props.conditions
|
|
38
|
+
var lpAddress = props.lpAddress, conditions = props.conditions;
|
|
39
39
|
var marketsMap = {};
|
|
40
40
|
conditions.forEach(function (_a) {
|
|
41
41
|
var conditionId = _a.conditionId, outcomes = _a.outcomes, coreAddress = _a.coreAddress;
|
|
42
42
|
outcomes.forEach(function (_a) {
|
|
43
43
|
var outcomeId = _a.outcomeId, rest = __rest(_a, ["outcomeId"]);
|
|
44
44
|
// we are using the same key format that was discussed earlier
|
|
45
|
-
var marketKey = dictionaries.getMarketKey(outcomeId
|
|
45
|
+
var marketKey = dictionaries.getMarketKey(outcomeId);
|
|
46
46
|
// we are obtaining the human-readable names of each market and the corresponding outcome selections
|
|
47
|
-
var marketName = dictionaries.getMarketName(outcomeId
|
|
48
|
-
var selectionName = dictionaries.
|
|
47
|
+
var marketName = dictionaries.getMarketName({ outcomeId: outcomeId });
|
|
48
|
+
var selectionName = dictionaries.getSelectionName({ outcomeId: outcomeId });
|
|
49
49
|
var outcome = __assign({ conditionId: conditionId, outcomeId: outcomeId, lpAddress: lpAddress, coreAddress: coreAddress, selectionName: selectionName }, rest);
|
|
50
50
|
if (!marketsMap[marketKey]) {
|
|
51
51
|
marketsMap[marketKey] = {
|
|
@@ -66,8 +66,8 @@ function __rest(s, e) {
|
|
|
66
66
|
};
|
|
67
67
|
// sort the outcomes by `selectionId` (outcome's selection reference)
|
|
68
68
|
outcomes.sort(function (a, b) {
|
|
69
|
-
var left = dictionaries
|
|
70
|
-
var right = dictionaries
|
|
69
|
+
var left = dictionaries.dictionaries.outcomes[a.outcomeId].selectionId;
|
|
70
|
+
var right = dictionaries.dictionaries.outcomes[b.outcomeId].selectionId;
|
|
71
71
|
return left - right;
|
|
72
72
|
});
|
|
73
73
|
// "Full Time Result" and "Double Chance" are the markets whose outcomes don't require sorting
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azuro-org/toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Set of helpers to work with Azuro protocol",
|
|
5
5
|
"module": "dist/index.es.js",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/Azuro-protocol/toolkit#readme",
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@azuro-org/dictionaries": "^
|
|
30
|
+
"@azuro-org/dictionaries": "^3.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@babel/core": "^7.17.0",
|