@xyo-network/coingecko-crypto-market-plugin 2.83.0 → 2.84.1
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/browser/Plugin.d.cts +581 -5
- package/dist/browser/Plugin.d.cts.map +1 -1
- package/dist/browser/Plugin.d.mts +581 -5
- package/dist/browser/Plugin.d.mts.map +1 -1
- package/dist/browser/Plugin.d.ts +581 -5
- package/dist/browser/Plugin.d.ts.map +1 -1
- package/dist/node/Plugin.d.cts +581 -5
- package/dist/node/Plugin.d.cts.map +1 -1
- package/dist/node/Plugin.d.mts +581 -5
- package/dist/node/Plugin.d.mts.map +1 -1
- package/dist/node/Plugin.d.ts +581 -5
- package/dist/node/Plugin.d.ts.map +1 -1
- package/dist/node/index.cjs +131 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.js +14 -47
- package/dist/node/index.js.map +1 -1
- package/package.json +17 -17
- package/dist/node/index.mjs +0 -98
- package/dist/node/index.mjs.map +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
CoingeckoCryptoMarketPlugin: () => CoingeckoCryptoMarketPlugin,
|
|
24
|
+
CoingeckoCryptoMarketWitness: () => CoingeckoCryptoMarketWitness,
|
|
25
|
+
CoingeckoCryptoMarketWitnessConfigSchema: () => CoingeckoCryptoMarketWitnessConfigSchema,
|
|
26
|
+
coingeckoCoinToAssetMap: () => coingeckoCoinToAssetMap,
|
|
27
|
+
default: () => src_default,
|
|
28
|
+
defaultCoins: () => defaultCoins,
|
|
29
|
+
defaultCurrencies: () => defaultCurrencies,
|
|
30
|
+
pricesFromCoingecko: () => pricesFromCoingecko
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
|
|
34
|
+
// src/Plugin.ts
|
|
35
|
+
var import_coingecko_crypto_market_payload_plugin2 = require("@xyo-network/coingecko-crypto-market-payload-plugin");
|
|
36
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
|
37
|
+
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
38
|
+
|
|
39
|
+
// src/Witness.ts
|
|
40
|
+
var import_abstract_witness = require("@xyo-network/abstract-witness");
|
|
41
|
+
var import_coingecko_crypto_market_payload_plugin = require("@xyo-network/coingecko-crypto-market-payload-plugin");
|
|
42
|
+
|
|
43
|
+
// src/lib/coinGeckoCoinToAssetMap.ts
|
|
44
|
+
var coingeckoCoinToAssetMap = {
|
|
45
|
+
"binance-usd": "busd",
|
|
46
|
+
bitcoin: "btc",
|
|
47
|
+
bnb: "bnb",
|
|
48
|
+
cardano: "ada",
|
|
49
|
+
dogecoin: "doge",
|
|
50
|
+
ethereum: "eth",
|
|
51
|
+
polkadot: "dot",
|
|
52
|
+
solana: "sol",
|
|
53
|
+
tether: "usdt",
|
|
54
|
+
"usd-coin": "usdc",
|
|
55
|
+
"wrapped-bitcoin": "wbtc",
|
|
56
|
+
xrp: "xrp",
|
|
57
|
+
"xyo-network": "xyo"
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/lib/defaults.ts
|
|
61
|
+
var defaultCoins = [
|
|
62
|
+
{ name: "bitcoin" },
|
|
63
|
+
{ name: "binance-usd" },
|
|
64
|
+
{ name: "bnb" },
|
|
65
|
+
{ name: "cardano" },
|
|
66
|
+
{ name: "dogecoin" },
|
|
67
|
+
{ name: "ethereum" },
|
|
68
|
+
{ name: "polkadot" },
|
|
69
|
+
{ name: "solana" },
|
|
70
|
+
{ name: "tether" },
|
|
71
|
+
{ name: "usd-coin" },
|
|
72
|
+
{ name: "wrapped-bitcoin" },
|
|
73
|
+
{ name: "xrp" },
|
|
74
|
+
{ name: "xyo-network" }
|
|
75
|
+
];
|
|
76
|
+
var defaultCurrencies = [{ symbol: "usd" }, { symbol: "eur" }, { symbol: "btc" }, { symbol: "eth" }];
|
|
77
|
+
|
|
78
|
+
// src/lib/pricesFromCoingecko.ts
|
|
79
|
+
var import_axios = require("@xylabs/axios");
|
|
80
|
+
var pricesFromCoingecko = async (coins, currencies) => {
|
|
81
|
+
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${coins.map(({ name }) => name).join(",")}&vs_currencies=${currencies.map(({ symbol }) => symbol).join(",")}`;
|
|
82
|
+
const coinGeckoSimplePrices = (await import_axios.axios.get(url)).data;
|
|
83
|
+
const assets = {};
|
|
84
|
+
Object.entries(coinGeckoSimplePrices).forEach(([key, value]) => {
|
|
85
|
+
assets[coingeckoCoinToAssetMap[key]] = value;
|
|
86
|
+
});
|
|
87
|
+
return assets;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// src/Schema.ts
|
|
91
|
+
var CoingeckoCryptoMarketWitnessConfigSchema = "network.xyo.crypto.market.coingecko.witness.config";
|
|
92
|
+
|
|
93
|
+
// src/Witness.ts
|
|
94
|
+
var CoingeckoCryptoMarketWitness = class extends import_abstract_witness.AbstractWitness {
|
|
95
|
+
static configSchemas = [CoingeckoCryptoMarketWitnessConfigSchema];
|
|
96
|
+
async observeHandler() {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
const assets = await pricesFromCoingecko(((_a = this.config) == null ? void 0 : _a.coins) ?? [], ((_b = this.config) == null ? void 0 : _b.currencies) ?? []);
|
|
99
|
+
const payload = {
|
|
100
|
+
assets,
|
|
101
|
+
schema: import_coingecko_crypto_market_payload_plugin.CoingeckoCryptoMarketSchema,
|
|
102
|
+
timestamp: Date.now()
|
|
103
|
+
};
|
|
104
|
+
return [payload];
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// src/Plugin.ts
|
|
109
|
+
var CoingeckoCryptoMarketPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
|
|
110
|
+
{ required: { [import_coingecko_crypto_market_payload_plugin2.CoingeckoCryptoMarketSchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
|
|
111
|
+
{
|
|
112
|
+
witness: async (params) => {
|
|
113
|
+
const result = await CoingeckoCryptoMarketWitness.create(params);
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// src/index.ts
|
|
120
|
+
var src_default = CoingeckoCryptoMarketPlugin;
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
CoingeckoCryptoMarketPlugin,
|
|
124
|
+
CoingeckoCryptoMarketWitness,
|
|
125
|
+
CoingeckoCryptoMarketWitnessConfigSchema,
|
|
126
|
+
coingeckoCoinToAssetMap,
|
|
127
|
+
defaultCoins,
|
|
128
|
+
defaultCurrencies,
|
|
129
|
+
pricesFromCoingecko
|
|
130
|
+
});
|
|
131
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts","../../src/lib/coinGeckoCoinToAssetMap.ts","../../src/lib/defaults.ts","../../src/lib/pricesFromCoingecko.ts","../../src/Schema.ts"],"sourcesContent":["import { CoingeckoCryptoMarketPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './lib'\nexport * from './Schema'\nexport * from './Witness'\n\nexport { CoingeckoCryptoMarketPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default CoingeckoCryptoMarketPlugin\n","import { CoingeckoCryptoMarketSchema } from '@xyo-network/coingecko-crypto-market-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CoingeckoCryptoMarketWitness } from './Witness'\n\nexport const CoingeckoCryptoMarketPlugin = () =>\n createPayloadSetWitnessPlugin<CoingeckoCryptoMarketWitness>(\n { required: { [CoingeckoCryptoMarketSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await CoingeckoCryptoMarketWitness.create(params)\n return result\n },\n },\n )\n","import { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { CoingeckoCryptoMarketPayload, CoingeckoCryptoMarketSchema } from '@xyo-network/coingecko-crypto-market-payload-plugin'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\n\nimport { CoingeckoCryptoMarketWitnessConfig } from './Config'\nimport { pricesFromCoingecko } from './lib'\nimport { CoingeckoCryptoMarketWitnessConfigSchema } from './Schema'\n\nexport type CoingeckoCryptoMarketWitnessParams = WitnessParams<AnyConfigSchema<CoingeckoCryptoMarketWitnessConfig>>\n\nexport class CoingeckoCryptoMarketWitness<\n TParams extends CoingeckoCryptoMarketWitnessParams = CoingeckoCryptoMarketWitnessParams,\n> extends AbstractWitness<TParams> {\n static override configSchemas = [CoingeckoCryptoMarketWitnessConfigSchema]\n\n protected override async observeHandler(): Promise<Payload[]> {\n const assets: CoingeckoCryptoMarketPayload['assets'] = await pricesFromCoingecko(this.config?.coins ?? [], this.config?.currencies ?? [])\n const payload: CoingeckoCryptoMarketPayload = {\n assets,\n schema: CoingeckoCryptoMarketSchema,\n timestamp: Date.now(),\n }\n\n return [payload]\n }\n}\n","import { AssetSymbol } from '@xyo-network/coingecko-crypto-market-payload-plugin'\n\nexport const coingeckoCoinToAssetMap: Record<string, AssetSymbol> = {\n 'binance-usd': 'busd',\n bitcoin: 'btc',\n bnb: 'bnb',\n cardano: 'ada',\n dogecoin: 'doge',\n ethereum: 'eth',\n polkadot: 'dot',\n solana: 'sol',\n tether: 'usdt',\n 'usd-coin': 'usdc',\n 'wrapped-bitcoin': 'wbtc',\n xrp: 'xrp',\n 'xyo-network': 'xyo',\n}\n","import { CryptoAsset } from '@xyo-network/coingecko-crypto-market-payload-plugin'\n\nexport const defaultCoins: CryptoAsset[] = [\n { name: 'bitcoin' },\n { name: 'binance-usd' },\n { name: 'bnb' },\n { name: 'cardano' },\n { name: 'dogecoin' },\n { name: 'ethereum' },\n { name: 'polkadot' },\n { name: 'solana' },\n { name: 'tether' },\n { name: 'usd-coin' },\n { name: 'wrapped-bitcoin' },\n { name: 'xrp' },\n { name: 'xyo-network' },\n]\n\nexport const defaultCurrencies: CryptoAsset[] = [{ symbol: 'usd' }, { symbol: 'eur' }, { symbol: 'btc' }, { symbol: 'eth' }]\n","import { axios } from '@xylabs/axios'\nimport { AssetSymbol, CryptoAsset, CryptoAssetPrices } from '@xyo-network/coingecko-crypto-market-payload-plugin'\n\nimport { coingeckoCoinToAssetMap } from './coinGeckoCoinToAssetMap'\n\ntype CoinGeckoSimplePrice = Partial<Record<AssetSymbol, number>>\ntype CoinGeckoSimplePrices = Record<string, CoinGeckoSimplePrice>\n\nexport const pricesFromCoingecko = async (coins: CryptoAsset[], currencies: CryptoAsset[]) => {\n const url = `https://api.coingecko.com/api/v3/simple/price?ids=${coins.map(({ name }) => name).join(',')}&vs_currencies=${currencies\n .map(({ symbol }) => symbol)\n .join(',')}`\n const coinGeckoSimplePrices = (await axios.get<CoinGeckoSimplePrices>(url)).data\n const assets: CryptoAssetPrices = {}\n Object.entries(coinGeckoSimplePrices).forEach(([key, value]) => {\n assets[coingeckoCoinToAssetMap[key]] = value\n })\n return assets\n}\n","export type CoingeckoCryptoMarketWitnessConfigSchema = 'network.xyo.crypto.market.coingecko.witness.config'\nexport const CoingeckoCryptoMarketWitnessConfigSchema: CoingeckoCryptoMarketWitnessConfigSchema = 'network.xyo.crypto.market.coingecko.witness.config'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iDAA4C;AAC5C,2BAAiC;AACjC,+BAA8C;;;ACF9C,8BAAgC;AAChC,oDAA0E;;;ACCnE,IAAM,0BAAuD;AAAA,EAClE,eAAe;AAAA,EACf,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,KAAK;AAAA,EACL,eAAe;AACjB;;;ACdO,IAAM,eAA8B;AAAA,EACzC,EAAE,MAAM,UAAU;AAAA,EAClB,EAAE,MAAM,cAAc;AAAA,EACtB,EAAE,MAAM,MAAM;AAAA,EACd,EAAE,MAAM,UAAU;AAAA,EAClB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,SAAS;AAAA,EACjB,EAAE,MAAM,SAAS;AAAA,EACjB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,kBAAkB;AAAA,EAC1B,EAAE,MAAM,MAAM;AAAA,EACd,EAAE,MAAM,cAAc;AACxB;AAEO,IAAM,oBA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}
|
package/dist/node/index.js
CHANGED
|
@@ -1,44 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
CoingeckoCryptoMarketPlugin: () => CoingeckoCryptoMarketPlugin,
|
|
24
|
-
CoingeckoCryptoMarketWitness: () => CoingeckoCryptoMarketWitness,
|
|
25
|
-
CoingeckoCryptoMarketWitnessConfigSchema: () => CoingeckoCryptoMarketWitnessConfigSchema,
|
|
26
|
-
coingeckoCoinToAssetMap: () => coingeckoCoinToAssetMap,
|
|
27
|
-
default: () => src_default,
|
|
28
|
-
defaultCoins: () => defaultCoins,
|
|
29
|
-
defaultCurrencies: () => defaultCurrencies,
|
|
30
|
-
pricesFromCoingecko: () => pricesFromCoingecko
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(src_exports);
|
|
33
|
-
|
|
34
1
|
// src/Plugin.ts
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
import { CoingeckoCryptoMarketSchema as CoingeckoCryptoMarketSchema2 } from "@xyo-network/coingecko-crypto-market-payload-plugin";
|
|
3
|
+
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
4
|
+
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
38
5
|
|
|
39
6
|
// src/Witness.ts
|
|
40
|
-
|
|
41
|
-
|
|
7
|
+
import { AbstractWitness } from "@xyo-network/abstract-witness";
|
|
8
|
+
import { CoingeckoCryptoMarketSchema } from "@xyo-network/coingecko-crypto-market-payload-plugin";
|
|
42
9
|
|
|
43
10
|
// src/lib/coinGeckoCoinToAssetMap.ts
|
|
44
11
|
var coingeckoCoinToAssetMap = {
|
|
@@ -76,10 +43,10 @@ var defaultCoins = [
|
|
|
76
43
|
var defaultCurrencies = [{ symbol: "usd" }, { symbol: "eur" }, { symbol: "btc" }, { symbol: "eth" }];
|
|
77
44
|
|
|
78
45
|
// src/lib/pricesFromCoingecko.ts
|
|
79
|
-
|
|
46
|
+
import { axios } from "@xylabs/axios";
|
|
80
47
|
var pricesFromCoingecko = async (coins, currencies) => {
|
|
81
48
|
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${coins.map(({ name }) => name).join(",")}&vs_currencies=${currencies.map(({ symbol }) => symbol).join(",")}`;
|
|
82
|
-
const coinGeckoSimplePrices = (await
|
|
49
|
+
const coinGeckoSimplePrices = (await axios.get(url)).data;
|
|
83
50
|
const assets = {};
|
|
84
51
|
Object.entries(coinGeckoSimplePrices).forEach(([key, value]) => {
|
|
85
52
|
assets[coingeckoCoinToAssetMap[key]] = value;
|
|
@@ -91,14 +58,14 @@ var pricesFromCoingecko = async (coins, currencies) => {
|
|
|
91
58
|
var CoingeckoCryptoMarketWitnessConfigSchema = "network.xyo.crypto.market.coingecko.witness.config";
|
|
92
59
|
|
|
93
60
|
// src/Witness.ts
|
|
94
|
-
var CoingeckoCryptoMarketWitness = class extends
|
|
61
|
+
var CoingeckoCryptoMarketWitness = class extends AbstractWitness {
|
|
95
62
|
static configSchemas = [CoingeckoCryptoMarketWitnessConfigSchema];
|
|
96
63
|
async observeHandler() {
|
|
97
64
|
var _a, _b;
|
|
98
65
|
const assets = await pricesFromCoingecko(((_a = this.config) == null ? void 0 : _a.coins) ?? [], ((_b = this.config) == null ? void 0 : _b.currencies) ?? []);
|
|
99
66
|
const payload = {
|
|
100
67
|
assets,
|
|
101
|
-
schema:
|
|
68
|
+
schema: CoingeckoCryptoMarketSchema,
|
|
102
69
|
timestamp: Date.now()
|
|
103
70
|
};
|
|
104
71
|
return [payload];
|
|
@@ -106,8 +73,8 @@ var CoingeckoCryptoMarketWitness = class extends import_abstract_witness.Abstrac
|
|
|
106
73
|
};
|
|
107
74
|
|
|
108
75
|
// src/Plugin.ts
|
|
109
|
-
var CoingeckoCryptoMarketPlugin = () =>
|
|
110
|
-
{ required: { [
|
|
76
|
+
var CoingeckoCryptoMarketPlugin = () => createPayloadSetWitnessPlugin(
|
|
77
|
+
{ required: { [CoingeckoCryptoMarketSchema2]: 1 }, schema: PayloadSetSchema },
|
|
111
78
|
{
|
|
112
79
|
witness: async (params) => {
|
|
113
80
|
const result = await CoingeckoCryptoMarketWitness.create(params);
|
|
@@ -118,14 +85,14 @@ var CoingeckoCryptoMarketPlugin = () => (0, import_payloadset_plugin.createPaylo
|
|
|
118
85
|
|
|
119
86
|
// src/index.ts
|
|
120
87
|
var src_default = CoingeckoCryptoMarketPlugin;
|
|
121
|
-
|
|
122
|
-
0 && (module.exports = {
|
|
88
|
+
export {
|
|
123
89
|
CoingeckoCryptoMarketPlugin,
|
|
124
90
|
CoingeckoCryptoMarketWitness,
|
|
125
91
|
CoingeckoCryptoMarketWitnessConfigSchema,
|
|
126
92
|
coingeckoCoinToAssetMap,
|
|
93
|
+
src_default as default,
|
|
127
94
|
defaultCoins,
|
|
128
95
|
defaultCurrencies,
|
|
129
96
|
pricesFromCoingecko
|
|
130
|
-
}
|
|
97
|
+
};
|
|
131
98
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts","../../src/lib/coinGeckoCoinToAssetMap.ts","../../src/lib/defaults.ts","../../src/lib/pricesFromCoingecko.ts","../../src/Schema.ts","../../src/index.ts"],"sourcesContent":["import { CoingeckoCryptoMarketSchema } from '@xyo-network/coingecko-crypto-market-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CoingeckoCryptoMarketWitness } from './Witness'\n\nexport const CoingeckoCryptoMarketPlugin = () =>\n createPayloadSetWitnessPlugin<CoingeckoCryptoMarketWitness>(\n { required: { [CoingeckoCryptoMarketSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await CoingeckoCryptoMarketWitness.create(params)\n return result\n },\n },\n )\n","import { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { CoingeckoCryptoMarketPayload, CoingeckoCryptoMarketSchema } from '@xyo-network/coingecko-crypto-market-payload-plugin'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\n\nimport { CoingeckoCryptoMarketWitnessConfig } from './Config'\nimport { pricesFromCoingecko } from './lib'\nimport { CoingeckoCryptoMarketWitnessConfigSchema } from './Schema'\n\nexport type CoingeckoCryptoMarketWitnessParams = WitnessParams<AnyConfigSchema<CoingeckoCryptoMarketWitnessConfig>>\n\nexport class CoingeckoCryptoMarketWitness<\n TParams extends CoingeckoCryptoMarketWitnessParams = CoingeckoCryptoMarketWitnessParams,\n> extends AbstractWitness<TParams> {\n static override configSchemas = [CoingeckoCryptoMarketWitnessConfigSchema]\n\n protected override async observeHandler(): Promise<Payload[]> {\n const assets: CoingeckoCryptoMarketPayload['assets'] = await pricesFromCoingecko(this.config?.coins ?? [], this.config?.currencies ?? [])\n const payload: CoingeckoCryptoMarketPayload = {\n assets,\n schema: CoingeckoCryptoMarketSchema,\n timestamp: Date.now(),\n }\n\n return [payload]\n }\n}\n","import { AssetSymbol } from '@xyo-network/coingecko-crypto-market-payload-plugin'\n\nexport const coingeckoCoinToAssetMap: Record<string, AssetSymbol> = {\n 'binance-usd': 'busd',\n bitcoin: 'btc',\n bnb: 'bnb',\n cardano: 'ada',\n dogecoin: 'doge',\n ethereum: 'eth',\n polkadot: 'dot',\n solana: 'sol',\n tether: 'usdt',\n 'usd-coin': 'usdc',\n 'wrapped-bitcoin': 'wbtc',\n xrp: 'xrp',\n 'xyo-network': 'xyo',\n}\n","import { CryptoAsset } from '@xyo-network/coingecko-crypto-market-payload-plugin'\n\nexport const defaultCoins: CryptoAsset[] = [\n { name: 'bitcoin' },\n { name: 'binance-usd' },\n { name: 'bnb' },\n { name: 'cardano' },\n { name: 'dogecoin' },\n { name: 'ethereum' },\n { name: 'polkadot' },\n { name: 'solana' },\n { name: 'tether' },\n { name: 'usd-coin' },\n { name: 'wrapped-bitcoin' },\n { name: 'xrp' },\n { name: 'xyo-network' },\n]\n\nexport const defaultCurrencies: CryptoAsset[] = [{ symbol: 'usd' }, { symbol: 'eur' }, { symbol: 'btc' }, { symbol: 'eth' }]\n","import { axios } from '@xylabs/axios'\nimport { AssetSymbol, CryptoAsset, CryptoAssetPrices } from '@xyo-network/coingecko-crypto-market-payload-plugin'\n\nimport { coingeckoCoinToAssetMap } from './coinGeckoCoinToAssetMap'\n\ntype CoinGeckoSimplePrice = Partial<Record<AssetSymbol, number>>\ntype CoinGeckoSimplePrices = Record<string, CoinGeckoSimplePrice>\n\nexport const pricesFromCoingecko = async (coins: CryptoAsset[], currencies: CryptoAsset[]) => {\n const url = `https://api.coingecko.com/api/v3/simple/price?ids=${coins.map(({ name }) => name).join(',')}&vs_currencies=${currencies\n .map(({ symbol }) => symbol)\n .join(',')}`\n const coinGeckoSimplePrices = (await axios.get<CoinGeckoSimplePrices>(url)).data\n const assets: CryptoAssetPrices = {}\n Object.entries(coinGeckoSimplePrices).forEach(([key, value]) => {\n assets[coingeckoCoinToAssetMap[key]] = value\n })\n return assets\n}\n","export type CoingeckoCryptoMarketWitnessConfigSchema = 'network.xyo.crypto.market.coingecko.witness.config'\nexport const CoingeckoCryptoMarketWitnessConfigSchema: CoingeckoCryptoMarketWitnessConfigSchema = 'network.xyo.crypto.market.coingecko.witness.config'\n","import { CoingeckoCryptoMarketPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './lib'\nexport * from './Schema'\nexport * from './Witness'\n\nexport { CoingeckoCryptoMarketPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default CoingeckoCryptoMarketPlugin\n"],"mappings":";AAAA,SAAS,+BAAAA,oCAAmC;AAC5C,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,uBAAuB;AAChC,SAAuC,mCAAmC;;;ACCnE,IAAM,0BAAuD;AAAA,EAClE,eAAe;AAAA,EACf,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,KAAK;AAAA,EACL,eAAe;AACjB;;;ACdO,IAAM,eAA8B;AAAA,EACzC,EAAE,MAAM,UAAU;AAAA,EAClB,EAAE,MAAM,cAAc;AAAA,EACtB,EAAE,MAAM,MAAM;AAAA,EACd,EAAE,MAAM,UAAU;AAAA,EAClB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,SAAS;AAAA,EACjB,EAAE,MAAM,SAAS;AAAA,EACjB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,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,MAAM;AAC/D,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;AMLF,IAAO,cAAQ;","names":["CoingeckoCryptoMarketSchema","CoingeckoCryptoMarketSchema"]}
|
package/package.json
CHANGED
|
@@ -11,22 +11,21 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/axios": "^2.13.20",
|
|
14
|
-
"@xyo-network/abstract-witness": "^2.
|
|
15
|
-
"@xyo-network/coingecko-crypto-market-payload-plugin": "~2.
|
|
16
|
-
"@xyo-network/module-model": "^2.
|
|
17
|
-
"@xyo-network/payload-model": "^2.
|
|
18
|
-
"@xyo-network/payloadset-plugin": "^2.
|
|
19
|
-
"@xyo-network/witness-model": "^2.
|
|
14
|
+
"@xyo-network/abstract-witness": "^2.84.3",
|
|
15
|
+
"@xyo-network/coingecko-crypto-market-payload-plugin": "~2.84.1",
|
|
16
|
+
"@xyo-network/module-model": "^2.84.3",
|
|
17
|
+
"@xyo-network/payload-model": "^2.84.3",
|
|
18
|
+
"@xyo-network/payloadset-plugin": "^2.84.3",
|
|
19
|
+
"@xyo-network/witness-model": "^2.84.3"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@xylabs/ts-scripts-yarn3": "^3.2.
|
|
23
|
-
"@xylabs/tsconfig": "^3.2.
|
|
24
|
-
"@xyo-network/account": "^2.
|
|
25
|
-
"@xyo-network/payload-wrapper": "^2.
|
|
22
|
+
"@xylabs/ts-scripts-yarn3": "^3.2.19",
|
|
23
|
+
"@xylabs/tsconfig": "^3.2.19",
|
|
24
|
+
"@xyo-network/account": "^2.84.3",
|
|
25
|
+
"@xyo-network/payload-wrapper": "^2.84.3",
|
|
26
26
|
"typescript": "^5.3.3"
|
|
27
27
|
},
|
|
28
28
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
29
|
-
"docs": "dist/docs.json",
|
|
30
29
|
"types": "dist/node/index.d.ts",
|
|
31
30
|
"exports": {
|
|
32
31
|
".": {
|
|
@@ -42,19 +41,19 @@
|
|
|
42
41
|
},
|
|
43
42
|
"node": {
|
|
44
43
|
"require": {
|
|
45
|
-
"types": "./dist/node/index.d.
|
|
46
|
-
"default": "./dist/node/index.
|
|
44
|
+
"types": "./dist/node/index.d.cts",
|
|
45
|
+
"default": "./dist/node/index.cjs"
|
|
47
46
|
},
|
|
48
47
|
"import": {
|
|
49
48
|
"types": "./dist/node/index.d.mts",
|
|
50
|
-
"default": "./dist/node/index.
|
|
49
|
+
"default": "./dist/node/index.js"
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
},
|
|
54
53
|
"./package.json": "./package.json"
|
|
55
54
|
},
|
|
56
|
-
"main": "dist/node/index.
|
|
57
|
-
"module": "dist/node/index.
|
|
55
|
+
"main": "dist/node/index.cjs",
|
|
56
|
+
"module": "dist/node/index.js",
|
|
58
57
|
"homepage": "https://xyo.network",
|
|
59
58
|
"license": "LGPL-3.0-only",
|
|
60
59
|
"publishConfig": {
|
|
@@ -65,5 +64,6 @@
|
|
|
65
64
|
"url": "https://github.com/XYOracleNetwork/plugins.git"
|
|
66
65
|
},
|
|
67
66
|
"sideEffects": false,
|
|
68
|
-
"version": "2.
|
|
67
|
+
"version": "2.84.1",
|
|
68
|
+
"type": "module"
|
|
69
69
|
}
|
package/dist/node/index.mjs
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// src/Plugin.ts
|
|
2
|
-
import { CoingeckoCryptoMarketSchema as CoingeckoCryptoMarketSchema2 } from "@xyo-network/coingecko-crypto-market-payload-plugin";
|
|
3
|
-
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
4
|
-
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
5
|
-
|
|
6
|
-
// src/Witness.ts
|
|
7
|
-
import { AbstractWitness } from "@xyo-network/abstract-witness";
|
|
8
|
-
import { CoingeckoCryptoMarketSchema } from "@xyo-network/coingecko-crypto-market-payload-plugin";
|
|
9
|
-
|
|
10
|
-
// src/lib/coinGeckoCoinToAssetMap.ts
|
|
11
|
-
var coingeckoCoinToAssetMap = {
|
|
12
|
-
"binance-usd": "busd",
|
|
13
|
-
bitcoin: "btc",
|
|
14
|
-
bnb: "bnb",
|
|
15
|
-
cardano: "ada",
|
|
16
|
-
dogecoin: "doge",
|
|
17
|
-
ethereum: "eth",
|
|
18
|
-
polkadot: "dot",
|
|
19
|
-
solana: "sol",
|
|
20
|
-
tether: "usdt",
|
|
21
|
-
"usd-coin": "usdc",
|
|
22
|
-
"wrapped-bitcoin": "wbtc",
|
|
23
|
-
xrp: "xrp",
|
|
24
|
-
"xyo-network": "xyo"
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// src/lib/defaults.ts
|
|
28
|
-
var defaultCoins = [
|
|
29
|
-
{ name: "bitcoin" },
|
|
30
|
-
{ name: "binance-usd" },
|
|
31
|
-
{ name: "bnb" },
|
|
32
|
-
{ name: "cardano" },
|
|
33
|
-
{ name: "dogecoin" },
|
|
34
|
-
{ name: "ethereum" },
|
|
35
|
-
{ name: "polkadot" },
|
|
36
|
-
{ name: "solana" },
|
|
37
|
-
{ name: "tether" },
|
|
38
|
-
{ name: "usd-coin" },
|
|
39
|
-
{ name: "wrapped-bitcoin" },
|
|
40
|
-
{ name: "xrp" },
|
|
41
|
-
{ name: "xyo-network" }
|
|
42
|
-
];
|
|
43
|
-
var defaultCurrencies = [{ symbol: "usd" }, { symbol: "eur" }, { symbol: "btc" }, { symbol: "eth" }];
|
|
44
|
-
|
|
45
|
-
// src/lib/pricesFromCoingecko.ts
|
|
46
|
-
import { axios } from "@xylabs/axios";
|
|
47
|
-
var pricesFromCoingecko = async (coins, currencies) => {
|
|
48
|
-
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${coins.map(({ name }) => name).join(",")}&vs_currencies=${currencies.map(({ symbol }) => symbol).join(",")}`;
|
|
49
|
-
const coinGeckoSimplePrices = (await axios.get(url)).data;
|
|
50
|
-
const assets = {};
|
|
51
|
-
Object.entries(coinGeckoSimplePrices).forEach(([key, value]) => {
|
|
52
|
-
assets[coingeckoCoinToAssetMap[key]] = value;
|
|
53
|
-
});
|
|
54
|
-
return assets;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// src/Schema.ts
|
|
58
|
-
var CoingeckoCryptoMarketWitnessConfigSchema = "network.xyo.crypto.market.coingecko.witness.config";
|
|
59
|
-
|
|
60
|
-
// src/Witness.ts
|
|
61
|
-
var CoingeckoCryptoMarketWitness = class extends AbstractWitness {
|
|
62
|
-
static configSchemas = [CoingeckoCryptoMarketWitnessConfigSchema];
|
|
63
|
-
async observeHandler() {
|
|
64
|
-
var _a, _b;
|
|
65
|
-
const assets = await pricesFromCoingecko(((_a = this.config) == null ? void 0 : _a.coins) ?? [], ((_b = this.config) == null ? void 0 : _b.currencies) ?? []);
|
|
66
|
-
const payload = {
|
|
67
|
-
assets,
|
|
68
|
-
schema: CoingeckoCryptoMarketSchema,
|
|
69
|
-
timestamp: Date.now()
|
|
70
|
-
};
|
|
71
|
-
return [payload];
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// src/Plugin.ts
|
|
76
|
-
var CoingeckoCryptoMarketPlugin = () => createPayloadSetWitnessPlugin(
|
|
77
|
-
{ required: { [CoingeckoCryptoMarketSchema2]: 1 }, schema: PayloadSetSchema },
|
|
78
|
-
{
|
|
79
|
-
witness: async (params) => {
|
|
80
|
-
const result = await CoingeckoCryptoMarketWitness.create(params);
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// src/index.ts
|
|
87
|
-
var src_default = CoingeckoCryptoMarketPlugin;
|
|
88
|
-
export {
|
|
89
|
-
CoingeckoCryptoMarketPlugin,
|
|
90
|
-
CoingeckoCryptoMarketWitness,
|
|
91
|
-
CoingeckoCryptoMarketWitnessConfigSchema,
|
|
92
|
-
coingeckoCoinToAssetMap,
|
|
93
|
-
src_default as default,
|
|
94
|
-
defaultCoins,
|
|
95
|
-
defaultCurrencies,
|
|
96
|
-
pricesFromCoingecko
|
|
97
|
-
};
|
|
98
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts","../../src/lib/coinGeckoCoinToAssetMap.ts","../../src/lib/defaults.ts","../../src/lib/pricesFromCoingecko.ts","../../src/Schema.ts","../../src/index.ts"],"sourcesContent":["import { CoingeckoCryptoMarketSchema } from '@xyo-network/coingecko-crypto-market-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CoingeckoCryptoMarketWitness } from './Witness'\n\nexport const CoingeckoCryptoMarketPlugin = () =>\n createPayloadSetWitnessPlugin<CoingeckoCryptoMarketWitness>(\n { required: { [CoingeckoCryptoMarketSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await CoingeckoCryptoMarketWitness.create(params)\n return result\n },\n },\n )\n","import { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { CoingeckoCryptoMarketPayload, CoingeckoCryptoMarketSchema } from '@xyo-network/coingecko-crypto-market-payload-plugin'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\n\nimport { CoingeckoCryptoMarketWitnessConfig } from './Config'\nimport { pricesFromCoingecko } from './lib'\nimport { CoingeckoCryptoMarketWitnessConfigSchema } from './Schema'\n\nexport type CoingeckoCryptoMarketWitnessParams = WitnessParams<AnyConfigSchema<CoingeckoCryptoMarketWitnessConfig>>\n\nexport class CoingeckoCryptoMarketWitness<\n TParams extends CoingeckoCryptoMarketWitnessParams = CoingeckoCryptoMarketWitnessParams,\n> extends AbstractWitness<TParams> {\n static override configSchemas = [CoingeckoCryptoMarketWitnessConfigSchema]\n\n protected override async observeHandler(): Promise<Payload[]> {\n const assets: CoingeckoCryptoMarketPayload['assets'] = await pricesFromCoingecko(this.config?.coins ?? [], this.config?.currencies ?? [])\n const payload: CoingeckoCryptoMarketPayload = {\n assets,\n schema: CoingeckoCryptoMarketSchema,\n timestamp: Date.now(),\n }\n\n return [payload]\n }\n}\n","import { AssetSymbol } from '@xyo-network/coingecko-crypto-market-payload-plugin'\n\nexport const coingeckoCoinToAssetMap: Record<string, AssetSymbol> = {\n 'binance-usd': 'busd',\n bitcoin: 'btc',\n bnb: 'bnb',\n cardano: 'ada',\n dogecoin: 'doge',\n ethereum: 'eth',\n polkadot: 'dot',\n solana: 'sol',\n tether: 'usdt',\n 'usd-coin': 'usdc',\n 'wrapped-bitcoin': 'wbtc',\n xrp: 'xrp',\n 'xyo-network': 'xyo',\n}\n","import { CryptoAsset } from '@xyo-network/coingecko-crypto-market-payload-plugin'\n\nexport const defaultCoins: CryptoAsset[] = [\n { name: 'bitcoin' },\n { name: 'binance-usd' },\n { name: 'bnb' },\n { name: 'cardano' },\n { name: 'dogecoin' },\n { name: 'ethereum' },\n { name: 'polkadot' },\n { name: 'solana' },\n { name: 'tether' },\n { name: 'usd-coin' },\n { name: 'wrapped-bitcoin' },\n { name: 'xrp' },\n { name: 'xyo-network' },\n]\n\nexport const defaultCurrencies: CryptoAsset[] = [{ symbol: 'usd' }, { symbol: 'eur' }, { symbol: 'btc' }, { symbol: 'eth' }]\n","import { axios } from '@xylabs/axios'\nimport { AssetSymbol, CryptoAsset, CryptoAssetPrices } from '@xyo-network/coingecko-crypto-market-payload-plugin'\n\nimport { coingeckoCoinToAssetMap } from './coinGeckoCoinToAssetMap'\n\ntype CoinGeckoSimplePrice = Partial<Record<AssetSymbol, number>>\ntype CoinGeckoSimplePrices = Record<string, CoinGeckoSimplePrice>\n\nexport const pricesFromCoingecko = async (coins: CryptoAsset[], currencies: CryptoAsset[]) => {\n const url = `https://api.coingecko.com/api/v3/simple/price?ids=${coins.map(({ name }) => name).join(',')}&vs_currencies=${currencies\n .map(({ symbol }) => symbol)\n .join(',')}`\n const coinGeckoSimplePrices = (await axios.get<CoinGeckoSimplePrices>(url)).data\n const assets: CryptoAssetPrices = {}\n Object.entries(coinGeckoSimplePrices).forEach(([key, value]) => {\n assets[coingeckoCoinToAssetMap[key]] = value\n })\n return assets\n}\n","export type CoingeckoCryptoMarketWitnessConfigSchema = 'network.xyo.crypto.market.coingecko.witness.config'\nexport const CoingeckoCryptoMarketWitnessConfigSchema: CoingeckoCryptoMarketWitnessConfigSchema = 'network.xyo.crypto.market.coingecko.witness.config'\n","import { CoingeckoCryptoMarketPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './lib'\nexport * from './Schema'\nexport * from './Witness'\n\nexport { CoingeckoCryptoMarketPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default CoingeckoCryptoMarketPlugin\n"],"mappings":";AAAA,SAAS,+BAAAA,oCAAmC;AAC5C,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,uBAAuB;AAChC,SAAuC,mCAAmC;;;ACCnE,IAAM,0BAAuD;AAAA,EAClE,eAAe;AAAA,EACf,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,KAAK;AAAA,EACL,eAAe;AACjB;;;ACdO,IAAM,eAA8B;AAAA,EACzC,EAAE,MAAM,UAAU;AAAA,EAClB,EAAE,MAAM,cAAc;AAAA,EACtB,EAAE,MAAM,MAAM;AAAA,EACd,EAAE,MAAM,UAAU;AAAA,EAClB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,WAAW;AAAA,EACnB,EAAE,MAAM,SAAS;AAAA,EACjB,EAAE,MAAM,SAAS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