@sonarwatch/portfolio-plugins 0.11.140 → 0.11.141
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/package.json +2 -2
- package/src/utils/misc/checkComputeAndStoreTokensPrices.js +1 -1
- package/src/utils/misc/checkComputeAndStoreTokensPrices.js.map +1 -1
- package/src/utils/misc/getDecimalsForToken.d.ts +1 -1
- package/src/utils/misc/getDecimalsForToken.js +9 -24
- package/src/utils/misc/getDecimalsForToken.js.map +1 -1
- package/src/utils/solana/getMultipleDecimals.js +2 -13
- package/src/utils/solana/getMultipleDecimals.js.map +1 -1
- package/src/utils/solana/getMultipleDecimalsAsMap.d.ts +3 -0
- package/src/utils/solana/getMultipleDecimalsAsMap.js +39 -0
- package/src/utils/solana/getMultipleDecimalsAsMap.js.map +1 -0
- package/src/utils/sui/getDecimals.d.ts +2 -0
- package/src/utils/sui/getDecimals.js +22 -0
- package/src/utils/sui/getDecimals.js.map +1 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.11.141](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.140...plugins-0.11.141) (2024-03-21)
|
6
|
+
|
7
|
+
|
8
|
+
|
5
9
|
## [0.11.140](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.139...plugins-0.11.140) (2024-03-21)
|
6
10
|
|
7
11
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sonarwatch/portfolio-plugins",
|
3
|
-
"version": "0.11.
|
3
|
+
"version": "0.11.141",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"web3-v1": "npm:web3@^1.5.0"
|
42
42
|
},
|
43
43
|
"peerDependencies": {
|
44
|
-
"@sonarwatch/portfolio-core": "0.11.
|
44
|
+
"@sonarwatch/portfolio-core": "0.11.141"
|
45
45
|
},
|
46
46
|
"main": "./src/index.js",
|
47
47
|
"types": "./src/index.d.ts"
|
@@ -125,7 +125,7 @@ function checkComputeAndStoreTokensPrices(cache, source, networkId, tokenX, toke
|
|
125
125
|
else {
|
126
126
|
decimalsTokenY = yield (0, getDecimalsForToken_1.getDecimalsForToken)(cache, tokenY.mint, networkId);
|
127
127
|
}
|
128
|
-
if (decimalsTokenX ===
|
128
|
+
if (decimalsTokenX === null || decimalsTokenY === null)
|
129
129
|
return undefined;
|
130
130
|
const tokenXReserve = tokenX.rawReserve.dividedBy(Math.pow(10, decimalsTokenX));
|
131
131
|
const tokenYReserve = tokenY.rawReserve.dividedBy(Math.pow(10, decimalsTokenY));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"checkComputeAndStoreTokensPrices.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/checkComputeAndStoreTokensPrices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAMoC;AAGpC,wEAAgD;AAChD,+DAA4D;AAC5D,8DAAsE;AAetE;;;;;;;;;GASG;AACU,QAAA,uBAAuB,GAAiC,IAAI,GAAG,CAAC;IAC3E;QACE,0BAAS,CAAC,GAAG;QACb;YACE,yBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;YAC3B,sEAAsE,EAAE,OAAO;YAC/E,qHAAqH,EAAE,SAAS;SACjI;KACF;IACD;QACE,0BAAS,CAAC,MAAM;QAChB;YACE,yBAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;YAC9B,2CAA0B,EAAE,OAAO;YACnC,8CAA8C,EAAE,WAAW;YAC3D,6CAA6C,EAAE,OAAO;YACtD,8CAA8C,EAAE,WAAW;YAC3D,8CAA8C,EAAE,OAAO;YACvD,8CAA8C,EAAE,OAAO;SACxD;KACF;IACD;QACE,0BAAS,CAAC,KAAK;QACf;YACE,yBAAQ,CAAC,KAAK,CAAC,MAAM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B,SAAS;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;aACzB,CAAC;YACF,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC;QAC9D,CAAC;QAED,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;YACjC,IAAI,
|
1
|
+
{"version":3,"file":"checkComputeAndStoreTokensPrices.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/checkComputeAndStoreTokensPrices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAMoC;AAGpC,wEAAgD;AAChD,+DAA4D;AAC5D,8DAAsE;AAetE;;;;;;;;;GASG;AACU,QAAA,uBAAuB,GAAiC,IAAI,GAAG,CAAC;IAC3E;QACE,0BAAS,CAAC,GAAG;QACb;YACE,yBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;YAC3B,sEAAsE,EAAE,OAAO;YAC/E,qHAAqH,EAAE,SAAS;SACjI;KACF;IACD;QACE,0BAAS,CAAC,MAAM;QAChB;YACE,yBAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;YAC9B,2CAA0B,EAAE,OAAO;YACnC,8CAA8C,EAAE,WAAW;YAC3D,6CAA6C,EAAE,OAAO;YACtD,8CAA8C,EAAE,WAAW;YAC3D,8CAA8C,EAAE,OAAO;YACvD,8CAA8C,EAAE,OAAO;SACxD;KACF;IACD;QACE,0BAAS,CAAC,KAAK;QACf;YACE,yBAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO;YAC7B,6EAA6E,EAAE,SAAS;YACxF,mFAAmF,EAAE,oBAAoB;SAC1G;KACF;IACD;QACE,0BAAS,CAAC,GAAG;QACb;YACE,yBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;YAC3B,gFAAgF,EAAE,SAAS;YAC3F,iFAAiF,EAAE,QAAQ;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MAAM;aACd,CAAC;YAEF,MAAM,KAAK,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;YACtD,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC;QAC9D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CAAA;AApID,mDAoIC"}
|
@@ -9,4 +9,4 @@ import { Cache } from '../../Cache';
|
|
9
9
|
*
|
10
10
|
* @returns The number of decimals or undefined if unsucessful request.
|
11
11
|
*/
|
12
|
-
export declare function getDecimalsForToken(cache: Cache, address: string, networkId: NetworkIdType): Promise<number |
|
12
|
+
export declare function getDecimalsForToken(cache: Cache, address: string, networkId: NetworkIdType): Promise<number | null>;
|
@@ -14,11 +14,12 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
|
14
14
|
const web3_js_1 = require("@solana/web3.js");
|
15
15
|
const core_1 = require("@sei-js/core");
|
16
16
|
const clients_1 = require("../clients");
|
17
|
-
const aptos_1 = require("../aptos");
|
18
17
|
const constants_1 = require("../clients/constants");
|
19
18
|
const sei_1 = require("../sei");
|
20
19
|
const constants_2 = require("../../plugins/tokens/constants");
|
21
|
-
const
|
20
|
+
const getDecimals_1 = require("../aptos/getDecimals");
|
21
|
+
const getDecimals_2 = require("../solana/getDecimals");
|
22
|
+
const getDecimals_3 = require("../sui/getDecimals");
|
22
23
|
/**
|
23
24
|
* Return the decimals of a token on any network using RPC calls or TokenList.
|
24
25
|
*
|
@@ -39,24 +40,11 @@ function getDecimalsForToken(cache, address, networkId) {
|
|
39
40
|
switch (networkId) {
|
40
41
|
case 'aptos': {
|
41
42
|
const client = (0, clients_1.getClientAptos)();
|
42
|
-
|
43
|
-
payload: {
|
44
|
-
function: aptos_1.coinDecimals,
|
45
|
-
typeArguments: [address],
|
46
|
-
functionArguments: [],
|
47
|
-
},
|
48
|
-
}));
|
49
|
-
if (viewRes.length !== 1)
|
50
|
-
return undefined;
|
51
|
-
return viewRes[0];
|
43
|
+
return (0, getDecimals_1.getDecimals)(client, address);
|
52
44
|
}
|
53
45
|
case 'solana': {
|
54
46
|
const client = (0, clients_1.getClientSolana)();
|
55
|
-
|
56
|
-
return 9;
|
57
|
-
}
|
58
|
-
const res = yield client.getTokenSupply(new web3_js_1.PublicKey(address));
|
59
|
-
return res.value.decimals ? res.value.decimals : undefined;
|
47
|
+
return (0, getDecimals_2.getDecimals)(client, new web3_js_1.PublicKey(address));
|
60
48
|
}
|
61
49
|
case 'sei': {
|
62
50
|
if (address.startsWith('factory')) {
|
@@ -69,21 +57,18 @@ function getDecimalsForToken(cache, address, networkId) {
|
|
69
57
|
}
|
70
58
|
if (address.startsWith('ibc')) {
|
71
59
|
// No solution yet for IBC tokens
|
72
|
-
return
|
60
|
+
return null;
|
73
61
|
}
|
74
62
|
if (address.startsWith('sei')) {
|
75
63
|
const client = yield (0, core_1.getCosmWasmClient)((0, constants_1.getUrlEndpoint)(portfolio_core_1.NetworkId.sei));
|
76
64
|
const tokenInfo = (yield client.queryContractSmart(address, sei_1.tokenInfoQueryMsg));
|
77
|
-
return tokenInfo.decimals ||
|
65
|
+
return tokenInfo.decimals || null;
|
78
66
|
}
|
79
|
-
return
|
67
|
+
return null;
|
80
68
|
}
|
81
69
|
case 'sui': {
|
82
70
|
const client = (0, clients_1.getClientSui)();
|
83
|
-
|
84
|
-
if (coinMetadata)
|
85
|
-
return coinMetadata.decimals;
|
86
|
-
return undefined;
|
71
|
+
return (0, getDecimals_3.getDecimals)(client, address);
|
87
72
|
}
|
88
73
|
default:
|
89
74
|
throw new Error('getDecimalsForToken : Network not supported');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getDecimalsForToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getDecimalsForToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"getDecimalsForToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getDecimalsForToken.ts"],"names":[],"mappings":";;;;;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C,CAAC,CAAC,QAAQ,CAAC;gBAC5C,CAAC;gBACD,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC9B,iCAAiC;oBACjC,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC9B,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAiB,EAAC,IAAA,0BAAc,EAAC,0BAAS,CAAC,GAAG,CAAC,CAAC,CAAC;oBACtE,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAChD,OAAO,EACP,uBAAiB,CAClB,CAAc,CAAC;oBAChB,OAAO,SAAS,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACpC,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YACD,KAAK,KAAK,CAAC,CAAC,CAAC;gBACX,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;gBAC9B,OAAO,IAAA,yBAAc,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CAAA;AArDD,kDAqDC"}
|
@@ -10,21 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.getMultipleDecimals = void 0;
|
13
|
-
const
|
14
|
-
const structs_1 = require("./structs");
|
15
|
-
const getParsedMultipleAccountsInfo_1 = require("./getParsedMultipleAccountsInfo");
|
16
|
-
const solMints = [portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeWrappedAddress];
|
13
|
+
const getMultipleDecimalsAsMap_1 = require("./getMultipleDecimalsAsMap");
|
17
14
|
function getMultipleDecimals(connection, mints) {
|
18
15
|
return __awaiter(this, void 0, void 0, function* () {
|
19
|
-
const
|
20
|
-
const decimalsMap = new Map();
|
21
|
-
decimalsMap.set(portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeDecimals);
|
22
|
-
decimalsMap.set(portfolio_core_1.solanaNativeWrappedAddress, portfolio_core_1.solanaNativeDecimals);
|
23
|
-
mintAccounts.forEach((acc) => {
|
24
|
-
if (!acc)
|
25
|
-
return;
|
26
|
-
decimalsMap.set(acc.pubkey.toString(), acc.decimals);
|
27
|
-
});
|
16
|
+
const decimalsMap = yield (0, getMultipleDecimalsAsMap_1.getMultipleDecimalsAsMap)(connection, mints);
|
28
17
|
return mints.map((m) => decimalsMap.get(m.toString()) || null);
|
29
18
|
});
|
30
19
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getMultipleDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getMultipleDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"getMultipleDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getMultipleDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yEAAsE;AAEtE,SAAsB,mBAAmB,CACvC,UAAwB,EACxB,KAAkB;;QAElB,MAAM,WAAW,GAAG,MAAM,IAAA,mDAAwB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACtE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC;IACjE,CAAC;CAAA;AAND,kDAMC"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.getMultipleDecimalsAsMap = void 0;
|
13
|
+
const web3_js_1 = require("@solana/web3.js");
|
14
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
15
|
+
const structs_1 = require("./structs");
|
16
|
+
const getParsedMultipleAccountsInfo_1 = require("./getParsedMultipleAccountsInfo");
|
17
|
+
function getMultipleDecimalsAsMap(connection, mints) {
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
19
|
+
const mintsSet = new Set(mints.map((m) => m.toString()));
|
20
|
+
const decimalsMap = new Map();
|
21
|
+
if (mintsSet.has(portfolio_core_1.solanaNativeAddress)) {
|
22
|
+
decimalsMap.set(portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeDecimals);
|
23
|
+
mintsSet.delete(portfolio_core_1.solanaNativeAddress);
|
24
|
+
}
|
25
|
+
if (mintsSet.has(portfolio_core_1.solanaNativeWrappedAddress)) {
|
26
|
+
decimalsMap.set(portfolio_core_1.solanaNativeWrappedAddress, portfolio_core_1.solanaNativeDecimals);
|
27
|
+
mintsSet.delete(portfolio_core_1.solanaNativeWrappedAddress);
|
28
|
+
}
|
29
|
+
const mintAccounts = yield (0, getParsedMultipleAccountsInfo_1.getParsedMultipleAccountsInfo)(connection, structs_1.mintAccountStruct, Array.from(mintsSet).map((m) => new web3_js_1.PublicKey(m)));
|
30
|
+
mintAccounts.forEach((acc) => {
|
31
|
+
if (!acc)
|
32
|
+
return;
|
33
|
+
decimalsMap.set(acc.pubkey.toString(), acc.decimals);
|
34
|
+
});
|
35
|
+
return decimalsMap;
|
36
|
+
});
|
37
|
+
}
|
38
|
+
exports.getMultipleDecimalsAsMap = getMultipleDecimalsAsMap;
|
39
|
+
//# sourceMappingURL=getMultipleDecimalsAsMap.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getMultipleDecimalsAsMap.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getMultipleDecimalsAsMap.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAC5C,+DAIoC;AAEpC,uCAA8C;AAC9C,mFAAgF;AAEhF,SAAsB,wBAAwB,CAC5C,UAAwB,EACxB,KAAkB;;QAElB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,WAAW,GAAwB,IAAI,GAAG,EAAE,CAAC;QAEnD,IAAI,QAAQ,CAAC,GAAG,CAAC,oCAAmB,CAAC,EAAE,CAAC;YACtC,WAAW,CAAC,GAAG,CAAC,oCAAmB,EAAE,qCAAoB,CAAC,CAAC;YAC3D,QAAQ,CAAC,MAAM,CAAC,oCAAmB,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,QAAQ,CAAC,GAAG,CAAC,2CAA0B,CAAC,EAAE,CAAC;YAC7C,WAAW,CAAC,GAAG,CAAC,2CAA0B,EAAE,qCAAoB,CAAC,CAAC;YAClE,QAAQ,CAAC,MAAM,CAAC,2CAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAA,6DAA6B,EACtD,UAAU,EACV,2BAAiB,EACjB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC,CAClD,CAAC;QACF,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC3B,IAAI,CAAC,GAAG;gBAAE,OAAO;YACjB,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;IACrB,CAAC;CAAA;AA1BD,4DA0BC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.getDecimals = void 0;
|
13
|
+
function getDecimals(client, coinType) {
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
15
|
+
const coinMetadata = yield client.getCoinMetadata({ coinType });
|
16
|
+
if (coinMetadata)
|
17
|
+
return coinMetadata.decimals;
|
18
|
+
return null;
|
19
|
+
});
|
20
|
+
}
|
21
|
+
exports.getDecimals = getDecimals;
|
22
|
+
//# sourceMappingURL=getDecimals.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/sui/getDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,SAAsB,WAAW,CAC/B,MAAiB,EACjB,QAAgB;;QAEhB,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChE,IAAI,YAAY;YAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAPD,kCAOC"}
|