@cityofzion/blockchain-service 1.19.2 → 1.19.3
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/helpers/BSUtilsHelper.js +4 -1
- package/dist/interfaces.d.ts +15 -15
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BSUtilsHelper = void 0;
|
|
13
|
+
const error_1 = require("../error");
|
|
13
14
|
class BSUtilsHelper {
|
|
14
15
|
static wait(ms) {
|
|
15
16
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
@@ -18,19 +19,21 @@ class BSUtilsHelper {
|
|
|
18
19
|
const { retries = 50, delay = 100, shouldRetry } = options || {};
|
|
19
20
|
// eslint-disable-next-line no-async-promise-executor
|
|
20
21
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
let errorMessage = '';
|
|
21
23
|
for (let i = 0; i < retries; i++) {
|
|
22
24
|
try {
|
|
23
25
|
const result = yield callback();
|
|
24
26
|
return resolve(result);
|
|
25
27
|
}
|
|
26
28
|
catch (error) {
|
|
29
|
+
errorMessage = error.message;
|
|
27
30
|
if (shouldRetry && !shouldRetry(error)) {
|
|
28
31
|
return reject(error);
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
yield this.wait(delay);
|
|
32
35
|
}
|
|
33
|
-
return reject(new
|
|
36
|
+
return reject(new error_1.BSError('Timeout: ' + errorMessage, 'TIMEOUT'));
|
|
34
37
|
}));
|
|
35
38
|
}
|
|
36
39
|
}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -360,8 +360,9 @@ export interface ISwapOrchestrator<BSName extends string = string> {
|
|
|
360
360
|
swap(): Promise<TSwapResult>;
|
|
361
361
|
calculateFee(): Promise<string>;
|
|
362
362
|
}
|
|
363
|
-
export type TBridgeToken = Token & {
|
|
363
|
+
export type TBridgeToken<BSName extends string = string> = Token & {
|
|
364
364
|
multichainId: string;
|
|
365
|
+
blockchain: BSName;
|
|
365
366
|
};
|
|
366
367
|
export type TBridgeValue<T> = {
|
|
367
368
|
value: T | null;
|
|
@@ -376,24 +377,23 @@ export type TBridgeOrchestratorEvents<BSName extends string = string> = {
|
|
|
376
377
|
amountToUse: (amount: TBridgeValidateValue<string>) => void | Promise<void>;
|
|
377
378
|
amountToUseMin: (max: TBridgeValue<string>) => void | Promise<void>;
|
|
378
379
|
amountToUseMax: (max: TBridgeValue<string>) => void | Promise<void>;
|
|
379
|
-
tokenToUse: (token: TBridgeValue<TBridgeToken
|
|
380
|
-
availableTokensToUse: (tokens: TBridgeValue<TBridgeToken[]>) => void | Promise<void>;
|
|
380
|
+
tokenToUse: (token: TBridgeValue<TBridgeToken<BSName>>) => void | Promise<void>;
|
|
381
|
+
availableTokensToUse: (tokens: TBridgeValue<TBridgeToken<BSName>[]>) => void | Promise<void>;
|
|
381
382
|
addressToReceive: (account: TBridgeValidateValue<string>) => void | Promise<void>;
|
|
382
383
|
amountToReceive: (amount: TBridgeValue<string>) => void | Promise<void>;
|
|
383
|
-
tokenToReceive: (token: TBridgeValue<TBridgeToken
|
|
384
|
+
tokenToReceive: (token: TBridgeValue<TBridgeToken<BSName>>) => void | Promise<void>;
|
|
384
385
|
tokenToUseBalance: (balance: TBridgeValue<BalanceResponse | undefined>) => void | Promise<void>;
|
|
385
386
|
bridgeFee: (fee: TBridgeValue<string>) => void | Promise<void>;
|
|
386
387
|
};
|
|
387
388
|
export interface IBridgeOrchestrator<BSName extends string = string> {
|
|
388
389
|
eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<BSName>>;
|
|
389
|
-
setTokenToUse(token: TBridgeToken | null): Promise<void>;
|
|
390
|
+
setTokenToUse(token: TBridgeToken<BSName> | null): Promise<void>;
|
|
390
391
|
setAccountToUse(account: Account<BSName> | null): Promise<void>;
|
|
391
392
|
setAmountToUse(amount: string | null): Promise<void>;
|
|
392
393
|
setAddressToReceive(address: string | null): Promise<void>;
|
|
393
394
|
setBalances(balances: BalanceResponse[] | null): Promise<void>;
|
|
394
395
|
switchTokens(): Promise<void>;
|
|
395
396
|
bridge(): Promise<string>;
|
|
396
|
-
wait(): Promise<boolean>;
|
|
397
397
|
}
|
|
398
398
|
export interface IBSWithNeo3NeoXBridge<BSName extends string = string> {
|
|
399
399
|
neo3NeoXBridgeService: INeo3NeoXBridgeService<BSName>;
|
|
@@ -407,27 +407,27 @@ export type TNeo3NeoXBridgeServiceBridgeParam<BSName extends string = string> =
|
|
|
407
407
|
account: Account<BSName>;
|
|
408
408
|
receiverAddress: string;
|
|
409
409
|
amount: string;
|
|
410
|
-
token: TBridgeToken
|
|
410
|
+
token: TBridgeToken<BSName>;
|
|
411
411
|
bridgeFee: string;
|
|
412
412
|
};
|
|
413
413
|
export type TNeo3NeoXBridgeServiceGetApprovalParam<BSName extends string = string> = {
|
|
414
414
|
account: Account<BSName>;
|
|
415
415
|
amount: string;
|
|
416
|
-
token: TBridgeToken
|
|
416
|
+
token: TBridgeToken<BSName>;
|
|
417
417
|
};
|
|
418
|
-
export type TNeo3NeoXBridgeServiceGetNonceParams = {
|
|
419
|
-
token: TBridgeToken
|
|
418
|
+
export type TNeo3NeoXBridgeServiceGetNonceParams<BSName extends string = string> = {
|
|
419
|
+
token: TBridgeToken<BSName>;
|
|
420
420
|
transactionHash: string;
|
|
421
421
|
};
|
|
422
|
-
export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams = {
|
|
423
|
-
token: TBridgeToken
|
|
422
|
+
export type TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<BSName extends string = string> = {
|
|
423
|
+
token: TBridgeToken<BSName>;
|
|
424
424
|
nonce: string;
|
|
425
425
|
};
|
|
426
426
|
export interface INeo3NeoXBridgeService<BSName extends string = string> {
|
|
427
|
-
tokens: TBridgeToken[];
|
|
427
|
+
tokens: TBridgeToken<BSName>[];
|
|
428
428
|
getApprovalFee(params: TNeo3NeoXBridgeServiceGetApprovalParam): Promise<string>;
|
|
429
429
|
getBridgeConstants(token: TBridgeToken): Promise<TNeo3NeoXBridgeServiceConstants>;
|
|
430
430
|
bridge(params: TNeo3NeoXBridgeServiceBridgeParam<BSName>): Promise<string>;
|
|
431
|
-
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams): Promise<string
|
|
432
|
-
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams): Promise<string
|
|
431
|
+
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<BSName>): Promise<string>;
|
|
432
|
+
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<BSName>): Promise<string>;
|
|
433
433
|
}
|