aftermath-ts-sdk 0.0.148 → 0.0.150

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 +1 @@
1
- {"version":3,"file":"coinGeckoPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/coingecko/coinGeckoPricesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkC,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,qBAAa,kBACZ,SAAQ,mBACR,YAAW,kBAAkB;gBAMjB,eAAe,EAAE,MAAM;IAgB5B,UAAU,SAAgB,MAAM,KAAG,QAAQ,MAAM,CAAC,CAEvD;IAEK,iBAAiB,UAAiB,QAAQ,EAAE;;OAkCjD;IAMK,oBAAoB,WAAkB;QAC5C,QAAQ,EAAE,QAAQ,CAAC;QACnB,SAAS,EAAE,kBAAkB,CAAC;KAC9B,KAAG,QAAQ,MAAM,CAAC,CAKjB;IAEK,4BAA4B,WAAkB;QACpD,YAAY,EAAE,OAAO,QAAQ,EAAE,kBAAkB,CAAC,CAAC;KACnD,KAAG,QAAQ,OAAO,QAAQ,EAAE,MAAM,CAAC,CAAC,CAYnC;CACF"}
1
+ {"version":3,"file":"coinGeckoPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/coingecko/coinGeckoPricesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,qBAAa,kBACZ,SAAQ,mBACR,YAAW,kBAAkB;gBAMjB,eAAe,EAAE,MAAM;IAgB5B,UAAU,SAAgB,MAAM,KAAG,QAAQ,MAAM,CAAC,CAEvD;IAEK,iBAAiB,UAAiB,QAAQ,EAAE;;OAkCjD;IAMK,oBAAoB,WAAkB;QAC5C,QAAQ,EAAE,QAAQ,CAAC;QACnB,SAAS,EAAE,kBAAkB,CAAC;KAC9B,KAAG,QAAQ,MAAM,CAAC,CAKjB;IAEK,4BAA4B,WAAkB;QACpD,YAAY,EAAE,OAAO,QAAQ,EAAE,kBAAkB,CAAC,CAAC;KACnD,KAAG,QAAQ,OAAO,QAAQ,EAAE,MAAM,CAAC,CAAC,CAYnC;CACF"}
@@ -1,10 +1,13 @@
1
- import { CoinType } from "../../../types";
1
+ import { CoinPriceInfo, CoinType } from "../../../types";
2
+ import { CoinGeckoCoinApiId } from "../coingecko/coinGeckoTypes";
2
3
  import { PricesApiInterface } from "../pricesApiInterface";
3
4
  export declare class PlaceholderPricesApi implements PricesApiInterface {
4
5
  private static readonly constants;
5
- constructor();
6
6
  fetchPrice: (coin: CoinType) => Promise<number>;
7
7
  fetchCoinsToPrice: (coins: CoinType[]) => Promise<Record<string, number>>;
8
+ fetchCoinsToPriceInfo: (inputs: {
9
+ coinsToApiId: Record<CoinType, CoinGeckoCoinApiId>;
10
+ }) => Promise<Record<CoinType, CoinPriceInfo>>;
8
11
  private fetchPrices;
9
12
  }
10
13
  //# sourceMappingURL=placeholderPricesApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"placeholderPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/placeholder/placeholderPricesApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,qBAAa,oBAAqB,YAAW,kBAAkB;IAK9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAkB/B;;IAgBK,UAAU,SAAgB,QAAQ,qBAEvC;IAEK,iBAAiB,UAAiB,QAAQ,EAAE,qCAajD;IAMF,OAAO,CAAC,WAAW,CAYjB;CACF"}
1
+ {"version":3,"file":"placeholderPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/placeholder/placeholderPricesApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,qBAAa,oBAAqB,YAAW,kBAAkB;IAK9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAkB/B;IAcK,UAAU,SAAgB,QAAQ,qBAEvC;IAEK,iBAAiB,UAAiB,QAAQ,EAAE,qCAajD;IAEK,qBAAqB,WAAkB;QAC7C,YAAY,EAAE,OAAO,QAAQ,EAAE,kBAAkB,CAAC,CAAC;KACnD,KAAG,QAAQ,OAAO,QAAQ,EAAE,aAAa,CAAC,CAAC,CAqB1C;IAuBF,OAAO,CAAC,WAAW,CAYjB;CACF"}
@@ -12,16 +12,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PlaceholderPricesApi = void 0;
13
13
  const coin_1 = require("../../../packages/coin/coin");
14
14
  class PlaceholderPricesApi {
15
- /////////////////////////////////////////////////////////////////////
16
- //// Constructor
17
- /////////////////////////////////////////////////////////////////////
18
15
  constructor() {
16
+ /////////////////////////////////////////////////////////////////////
17
+ //// Constants
18
+ /////////////////////////////////////////////////////////////////////
19
19
  /////////////////////////////////////////////////////////////////////
20
20
  //// Fetching
21
21
  /////////////////////////////////////////////////////////////////////
22
22
  /////////////////////////////////////////////////////////////////////
23
23
  //// Public
24
24
  /////////////////////////////////////////////////////////////////////
25
+ /////////////////////////////////////////////////////////////////////
26
+ //// Interface Methods
27
+ /////////////////////////////////////////////////////////////////////
25
28
  this.fetchPrice = (coin) => __awaiter(this, void 0, void 0, function* () {
26
29
  return (yield this.fetchPrices([coin]))[0];
27
30
  });
@@ -32,6 +35,32 @@ class PlaceholderPricesApi {
32
35
  }, {});
33
36
  return coinsToPrice;
34
37
  });
38
+ this.fetchCoinsToPriceInfo = (inputs) => __awaiter(this, void 0, void 0, function* () {
39
+ const { coinsToApiId } = inputs;
40
+ if (Object.keys(coinsToApiId).length <= 0)
41
+ return {};
42
+ const coinsToPrice = yield this.fetchCoinsToPrice(Object.keys(inputs.coinsToApiId));
43
+ const coinsInfo = Object.entries(coinsToPrice).reduce((acc, [coin, price]) => (Object.assign(Object.assign({}, acc), { [coin]: {
44
+ price,
45
+ priceChange24HoursPercentage: Math.random() > 0.5 ? 0 : (Math.random() - 0.5) / 10,
46
+ } })), {});
47
+ return coinsInfo;
48
+ });
49
+ // public fetchPriceGivenApiId = async (inputs: {
50
+ // coinType: CoinType;
51
+ // coinApiId: CoinGeckoCoinApiId;
52
+ // }): Promise<number> => {
53
+ // const charCode = inputs.coinType.charCodeAt(0);
54
+ // return isNaN(charCode) ? 0 : charCode;
55
+ // };
56
+ // public fetchCoinsToPriceGivenApiIds = async (inputs: {
57
+ // coinsToApiId: Record<CoinType, CoinGeckoCoinApiId>;
58
+ // }): Promise<Record<CoinType, number>> => {
59
+ // const coinsToPrice = await this.fetchCoinsToPrice(
60
+ // Object.keys(inputs.coinsToApiId)
61
+ // );
62
+ // return coinsToPrice;
63
+ // };
35
64
  /////////////////////////////////////////////////////////////////////
36
65
  //// Private
37
66
  /////////////////////////////////////////////////////////////////////
@@ -45,9 +74,6 @@ class PlaceholderPricesApi {
45
74
  }
46
75
  }
47
76
  exports.PlaceholderPricesApi = PlaceholderPricesApi;
48
- /////////////////////////////////////////////////////////////////////
49
- //// Constants
50
- /////////////////////////////////////////////////////////////////////
51
77
  PlaceholderPricesApi.constants = {
52
78
  prices: {
53
79
  usdc: 1,
@@ -1,6 +1,10 @@
1
- import { CoinType } from "../../types";
1
+ import { CoinPriceInfo, CoinType } from "../../types";
2
+ import { CoinGeckoCoinApiId } from "./coingecko/coinGeckoTypes";
2
3
  export interface PricesApiInterface {
3
4
  fetchPrice: (coin: CoinType) => Promise<number>;
4
5
  fetchCoinsToPrice: (coins: CoinType[]) => Promise<Record<CoinType, number>>;
6
+ fetchCoinsToPriceInfo: (inputs: {
7
+ coinsToApiId: Record<CoinType, CoinGeckoCoinApiId>;
8
+ }) => Promise<Record<CoinType, CoinPriceInfo>>;
5
9
  }
6
10
  //# sourceMappingURL=pricesApiInterface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pricesApiInterface.d.ts","sourceRoot":"","sources":["../../../src/general/prices/pricesApiInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,WAAW,kBAAkB;IAClC,UAAU,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,iBAAiB,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;CAC5E"}
1
+ {"version":3,"file":"pricesApiInterface.d.ts","sourceRoot":"","sources":["../../../src/general/prices/pricesApiInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,WAAW,kBAAkB;IAClC,UAAU,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,iBAAiB,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAU5E,qBAAqB,EAAE,CAAC,MAAM,EAAE;QAC/B,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;KACnD,KAAK,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;CAC/C"}
@@ -1,10 +1,2 @@
1
- import { CoinSymbolToCoinTypes, CoinType } from "../../../types";
2
- import { PricesApiInterface } from "../pricesApiInterface";
3
- import { PythPricesApiHelpers } from "./pythPricesApiHelpers";
4
- export declare class PythPricesApi extends PythPricesApiHelpers implements PricesApiInterface {
5
- constructor(coinSymbolToCoinTypes: CoinSymbolToCoinTypes);
6
- fetchPrice: (coin: CoinType) => Promise<number>;
7
- fetchCoinsToPrice: (coins: CoinType[]) => Promise<Record<string, number>>;
8
- private fetchPrices;
9
- }
1
+ export {};
10
2
  //# sourceMappingURL=pythPricesApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pythPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/pyth/pythPricesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,qBAAa,aACZ,SAAQ,oBACR,YAAW,kBAAkB;gBAMjB,qBAAqB,EAAE,qBAAqB;IAYjD,UAAU,SAAgB,QAAQ,qBAEvC;IAEK,iBAAiB,UAAiB,QAAQ,EAAE,qCAYjD;IAMF,OAAO,CAAC,WAAW,CAajB;CACF"}
1
+ {"version":3,"file":"pythPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/pyth/pythPricesApi.ts"],"names":[],"mappings":""}
@@ -1,54 +1,52 @@
1
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
- };
2
+ // import { CoinSymbolToCoinTypes, CoinType } from "../../../types";
3
+ // import { PricesApiInterface } from "../pricesApiInterface";
4
+ // import { PythPricesApiHelpers } from "./pythPricesApiHelpers";
11
5
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PythPricesApi = void 0;
13
- const pythPricesApiHelpers_1 = require("./pythPricesApiHelpers");
14
- class PythPricesApi extends pythPricesApiHelpers_1.PythPricesApiHelpers {
15
- /////////////////////////////////////////////////////////////////////
16
- //// Constructor
17
- /////////////////////////////////////////////////////////////////////
18
- constructor(coinSymbolToCoinTypes) {
19
- super(coinSymbolToCoinTypes);
20
- /////////////////////////////////////////////////////////////////////
21
- //// Fetching
22
- /////////////////////////////////////////////////////////////////////
23
- /////////////////////////////////////////////////////////////////////
24
- //// Public
25
- /////////////////////////////////////////////////////////////////////
26
- this.fetchPrice = (coin) => __awaiter(this, void 0, void 0, function* () {
27
- return (yield this.fetchPrices([coin]))[0];
28
- });
29
- this.fetchCoinsToPrice = (coins) => __awaiter(this, void 0, void 0, function* () {
30
- const prices = yield this.fetchPrices(coins);
31
- const coinsToPrice = coins.reduce((acc, coin, index) => {
32
- return Object.assign(Object.assign({}, acc), { [coin]: prices[index] });
33
- }, {});
34
- return coinsToPrice;
35
- });
36
- /////////////////////////////////////////////////////////////////////
37
- //// Private
38
- /////////////////////////////////////////////////////////////////////
39
- this.fetchPrices = (coins) => __awaiter(this, void 0, void 0, function* () {
40
- const priceFeeds = yield this.fetchPriceFeeds(coins);
41
- const prices = priceFeeds.map((priceFeed) => {
42
- // TODO: handle this differently ? - will cause breaking changes in FE
43
- if (priceFeed === undefined)
44
- return -1;
45
- const price = priceFeed.getPriceAsNumberUnchecked();
46
- if (price <= 0)
47
- return -1;
48
- return price;
49
- });
50
- return prices;
51
- });
52
- }
53
- }
54
- exports.PythPricesApi = PythPricesApi;
6
+ // export class PythPricesApi
7
+ // extends PythPricesApiHelpers
8
+ // implements PricesApiInterface
9
+ // {
10
+ // /////////////////////////////////////////////////////////////////////
11
+ // //// Constructor
12
+ // /////////////////////////////////////////////////////////////////////
13
+ // constructor(coinSymbolToCoinTypes: CoinSymbolToCoinTypes) {
14
+ // super(coinSymbolToCoinTypes);
15
+ // }
16
+ // /////////////////////////////////////////////////////////////////////
17
+ // //// Fetching
18
+ // /////////////////////////////////////////////////////////////////////
19
+ // /////////////////////////////////////////////////////////////////////
20
+ // //// Public
21
+ // /////////////////////////////////////////////////////////////////////
22
+ // public fetchPrice = async (coin: CoinType) => {
23
+ // return (await this.fetchPrices([coin]))[0];
24
+ // };
25
+ // public fetchCoinsToPrice = async (coins: CoinType[]) => {
26
+ // const prices = await this.fetchPrices(coins);
27
+ // const coinsToPrice: Record<CoinType, number> = coins.reduce(
28
+ // (acc, coin, index) => {
29
+ // return {
30
+ // ...acc,
31
+ // [coin]: prices[index],
32
+ // };
33
+ // },
34
+ // {}
35
+ // );
36
+ // return coinsToPrice;
37
+ // };
38
+ // /////////////////////////////////////////////////////////////////////
39
+ // //// Private
40
+ // /////////////////////////////////////////////////////////////////////
41
+ // private fetchPrices = async (coins: CoinType[]) => {
42
+ // const priceFeeds = await this.fetchPriceFeeds(coins);
43
+ // const prices = priceFeeds.map((priceFeed) => {
44
+ // // TODO: handle this differently ? - will cause breaking changes in FE
45
+ // if (priceFeed === undefined) return -1;
46
+ // const price = priceFeed.getPriceAsNumberUnchecked();
47
+ // if (price <= 0) return -1;
48
+ // return price;
49
+ // });
50
+ // return prices;
51
+ // };
52
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aftermath-ts-sdk",
3
- "version": "0.0.148",
3
+ "version": "0.0.150",
4
4
  "description": "Aftermath TypeScript SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",