@cityofzion/blockchain-service 1.17.0 → 1.17.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/constants/BSCommonConstants.d.ts +3 -0
- package/dist/constants/BSCommonConstants.js +7 -0
- package/dist/functions.d.ts +1 -1
- package/dist/functions.js +2 -0
- package/dist/helpers/BSFullTransactionsByAddressHelper.d.ts +4 -0
- package/dist/helpers/BSFullTransactionsByAddressHelper.js +25 -0
- package/dist/helpers/BSPromisesHelper.d.ts +3 -0
- package/dist/helpers/BSPromisesHelper.js +26 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interfaces.d.ts +54 -0
- package/package.json +3 -2
package/dist/functions.d.ts
CHANGED
|
@@ -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
|
|
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,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,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);
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -118,6 +118,57 @@ 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
|
+
nextCursor?: string;
|
|
126
|
+
};
|
|
127
|
+
export type FullTransactionNftEvent = {
|
|
128
|
+
eventType: 'nft';
|
|
129
|
+
amount: string;
|
|
130
|
+
methodName: string;
|
|
131
|
+
hash: string;
|
|
132
|
+
hashUrl?: string;
|
|
133
|
+
to?: string;
|
|
134
|
+
toUrl?: string;
|
|
135
|
+
from?: string;
|
|
136
|
+
fromUrl?: string;
|
|
137
|
+
tokenType: 'generic' | (string & NonNullable<unknown>);
|
|
138
|
+
tokenId?: string;
|
|
139
|
+
nftImageUrl?: string;
|
|
140
|
+
nftUrl?: string;
|
|
141
|
+
name?: string;
|
|
142
|
+
collectionName?: string;
|
|
143
|
+
};
|
|
144
|
+
export type FullTransactionAssetEvent = {
|
|
145
|
+
eventType: 'token';
|
|
146
|
+
amount: string;
|
|
147
|
+
methodName: string;
|
|
148
|
+
hash: string;
|
|
149
|
+
hashUrl?: string;
|
|
150
|
+
to?: string;
|
|
151
|
+
toUrl?: string;
|
|
152
|
+
from?: string;
|
|
153
|
+
fromUrl?: string;
|
|
154
|
+
token?: Token;
|
|
155
|
+
tokenType: 'generic' | (string & NonNullable<unknown>);
|
|
156
|
+
};
|
|
157
|
+
export type FullTransactionsItem = {
|
|
158
|
+
txId: string;
|
|
159
|
+
txIdUrl?: string;
|
|
160
|
+
block: number;
|
|
161
|
+
date: string;
|
|
162
|
+
invocationCount: number;
|
|
163
|
+
notificationCount: number;
|
|
164
|
+
networkFeeAmount: string;
|
|
165
|
+
systemFeeAmount: string;
|
|
166
|
+
events: (FullTransactionAssetEvent | FullTransactionNftEvent)[];
|
|
167
|
+
};
|
|
168
|
+
export type FullTransactionsByAddressResponse = {
|
|
169
|
+
nextCursor?: string;
|
|
170
|
+
data: FullTransactionsItem[];
|
|
171
|
+
};
|
|
121
172
|
export type ContractMethod = {
|
|
122
173
|
name: string;
|
|
123
174
|
parameters: ContractParameter[];
|
|
@@ -140,6 +191,7 @@ export interface BlockchainDataService {
|
|
|
140
191
|
maxTimeToConfirmTransactionInMs: number;
|
|
141
192
|
getTransaction(txid: string): Promise<TransactionResponse>;
|
|
142
193
|
getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
194
|
+
getFullTransactionsByAddress(params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
143
195
|
getContract(contractHash: string): Promise<ContractResponse>;
|
|
144
196
|
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
145
197
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
@@ -219,6 +271,8 @@ export interface ExplorerService {
|
|
|
219
271
|
buildNftUrl(params: BuildNftUrlParams): string;
|
|
220
272
|
getAddressTemplateUrl(): string | undefined;
|
|
221
273
|
getTxTemplateUrl(): string | undefined;
|
|
274
|
+
getNftTemplateUrl(): string | undefined;
|
|
275
|
+
getContractTemplateUrl(): string | undefined;
|
|
222
276
|
}
|
|
223
277
|
export type LedgerServiceEmitter = TypedEmitter<{
|
|
224
278
|
getSignatureStart(): void | Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/blockchain-service",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.1",
|
|
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.
|
|
23
|
+
"axios": "1.8.2",
|
|
24
|
+
"date-fns": "~4.1.0"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"build": "tsc",
|