@cityofzion/blockchain-service 1.17.0 → 1.18.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.
@@ -0,0 +1,3 @@
1
+ export declare class BSCommonConstants {
2
+ static readonly DORA_URL = "https://dora.coz.io";
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BSCommonConstants = void 0;
4
+ class BSCommonConstants {
5
+ }
6
+ exports.BSCommonConstants = BSCommonConstants;
7
+ BSCommonConstants.DORA_URL = 'https://dora.coz.io';
@@ -25,5 +25,5 @@ type NormalizedHashOptions = {
25
25
  export declare function normalizeHash(hash: string, options?: NormalizedHashOptions): string;
26
26
  export declare function denormalizeHash(hash: string): string;
27
27
  export declare function countDecimals(value: string | number): number;
28
- export declare function formatNumber(value: string | number, decimals?: number): string;
28
+ export declare function formatNumber(value?: string | number, decimals?: number): string;
29
29
  export {};
package/dist/functions.js CHANGED
@@ -159,6 +159,8 @@ function countDecimals(value) {
159
159
  }
160
160
  exports.countDecimals = countDecimals;
161
161
  function formatNumber(value, decimals = 0) {
162
+ if (!value)
163
+ return '0';
162
164
  let newValue = typeof value === 'number' ? value.toFixed(decimals) : value;
163
165
  newValue = newValue.replace(/,|\.\.|\.,/g, '.');
164
166
  if (decimals === 0) {
@@ -0,0 +1,4 @@
1
+ import { FullTransactionsByAddressParams } from '../interfaces';
2
+ export declare class BSFullTransactionsByAddressHelper {
3
+ static validateFullTransactionsByAddressParams(params: Omit<FullTransactionsByAddressParams, 'nextCursor'>): void;
4
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BSFullTransactionsByAddressHelper = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ class BSFullTransactionsByAddressHelper {
6
+ static validateFullTransactionsByAddressParams(params) {
7
+ if (!params.dateFrom)
8
+ throw new Error('Missing dateFrom param');
9
+ if (!params.dateTo)
10
+ throw new Error('Missing dateTo param');
11
+ const dateFrom = (0, date_fns_1.parseISO)(params.dateFrom);
12
+ const dateTo = (0, date_fns_1.parseISO)(params.dateTo);
13
+ if (!(0, date_fns_1.isValid)(dateFrom))
14
+ throw new Error('Invalid dateFrom param');
15
+ if (!(0, date_fns_1.isValid)(dateTo))
16
+ throw new Error('Invalid dateTo param');
17
+ if ((0, date_fns_1.isFuture)(dateFrom) || (0, date_fns_1.isFuture)(dateTo))
18
+ throw new Error('The dateFrom and/or dateTo are in future');
19
+ if ((0, date_fns_1.isAfter)(dateFrom, dateTo))
20
+ throw new Error('Invalid date order because dateFrom is greater than dateTo');
21
+ if ((0, date_fns_1.differenceInYears)(dateTo, dateFrom) >= 1)
22
+ throw new Error('Date range greater than one year');
23
+ }
24
+ }
25
+ exports.BSFullTransactionsByAddressHelper = BSFullTransactionsByAddressHelper;
@@ -0,0 +1,3 @@
1
+ export declare class BSPromisesHelper {
2
+ static tryCatch<T = any>(callback: () => T | Promise<T>): Promise<[T | null, any]>;
3
+ }
@@ -0,0 +1,26 @@
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.BSPromisesHelper = void 0;
13
+ class BSPromisesHelper {
14
+ static tryCatch(callback) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ try {
17
+ const result = yield callback();
18
+ return [result, null];
19
+ }
20
+ catch (error) {
21
+ return [null, error];
22
+ }
23
+ });
24
+ }
25
+ }
26
+ exports.BSPromisesHelper = BSPromisesHelper;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export * from './constants/BSCommonConstants';
2
+ export * from './helpers/BSFullTransactionsByAddressHelper';
3
+ export * from './helpers/BSPromisesHelper';
1
4
  export * from './services/exchange-data/CryptoCompareEDS';
2
5
  export * from './services/exchange-data/FlamingoForthewinEDS';
3
6
  export * from './BSAggregator';
package/dist/index.js CHANGED
@@ -14,6 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants/BSCommonConstants"), exports);
18
+ __exportStar(require("./helpers/BSFullTransactionsByAddressHelper"), exports);
19
+ __exportStar(require("./helpers/BSPromisesHelper"), exports);
17
20
  __exportStar(require("./services/exchange-data/CryptoCompareEDS"), exports);
18
21
  __exportStar(require("./services/exchange-data/FlamingoForthewinEDS"), exports);
19
22
  __exportStar(require("./BSAggregator"), exports);
@@ -118,6 +118,63 @@ export type TransactionsByAddressParams = {
118
118
  address: string;
119
119
  nextPageParams?: any;
120
120
  };
121
+ export type FullTransactionsByAddressParams = {
122
+ address: string;
123
+ dateFrom: string;
124
+ dateTo: string;
125
+ pageSize?: number;
126
+ nextCursor?: string;
127
+ };
128
+ export type ExportTransactionsByAddressParams = {
129
+ address: string;
130
+ dateFrom: string;
131
+ dateTo: string;
132
+ };
133
+ export type FullTransactionNftEvent = {
134
+ eventType: 'nft';
135
+ amount: string;
136
+ methodName: string;
137
+ hash: string;
138
+ hashUrl?: string;
139
+ to?: string;
140
+ toUrl?: string;
141
+ from?: string;
142
+ fromUrl?: string;
143
+ tokenType: 'generic' | (string & NonNullable<unknown>);
144
+ tokenId?: string;
145
+ nftImageUrl?: string;
146
+ nftUrl?: string;
147
+ name?: string;
148
+ collectionName?: string;
149
+ };
150
+ export type FullTransactionAssetEvent = {
151
+ eventType: 'token';
152
+ amount: string;
153
+ methodName: string;
154
+ hash: string;
155
+ hashUrl?: string;
156
+ to?: string;
157
+ toUrl?: string;
158
+ from?: string;
159
+ fromUrl?: string;
160
+ token?: Token;
161
+ tokenType: 'generic' | (string & NonNullable<unknown>);
162
+ };
163
+ export type FullTransactionsItem = {
164
+ txId: string;
165
+ txIdUrl?: string;
166
+ block: number;
167
+ date: string;
168
+ invocationCount: number;
169
+ notificationCount: number;
170
+ networkFeeAmount: string;
171
+ systemFeeAmount: string;
172
+ events: (FullTransactionAssetEvent | FullTransactionNftEvent)[];
173
+ };
174
+ export type FullTransactionsByAddressResponse = {
175
+ nextCursor?: string;
176
+ data: FullTransactionsItem[];
177
+ };
121
178
  export type ContractMethod = {
122
179
  name: string;
123
180
  parameters: ContractParameter[];
@@ -140,6 +197,8 @@ export interface BlockchainDataService {
140
197
  maxTimeToConfirmTransactionInMs: number;
141
198
  getTransaction(txid: string): Promise<TransactionResponse>;
142
199
  getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
200
+ getFullTransactionsByAddress(params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
201
+ exportFullTransactionsByAddress(params: ExportTransactionsByAddressParams): Promise<string>;
143
202
  getContract(contractHash: string): Promise<ContractResponse>;
144
203
  getTokenInfo(tokenHash: string): Promise<Token>;
145
204
  getBalance(address: string): Promise<BalanceResponse[]>;
@@ -219,6 +278,8 @@ export interface ExplorerService {
219
278
  buildNftUrl(params: BuildNftUrlParams): string;
220
279
  getAddressTemplateUrl(): string | undefined;
221
280
  getTxTemplateUrl(): string | undefined;
281
+ getNftTemplateUrl(): string | undefined;
282
+ getContractTemplateUrl(): string | undefined;
222
283
  }
223
284
  export type LedgerServiceEmitter = TypedEmitter<{
224
285
  getSignatureStart(): void | Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/blockchain-service",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -20,7 +20,8 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@ledgerhq/hw-transport": "~6.30.5",
23
- "axios": "1.5.1"
23
+ "axios": "1.8.2",
24
+ "date-fns": "~4.1.0"
24
25
  },
25
26
  "scripts": {
26
27
  "build": "tsc",