@cityofzion/blockchain-service 1.8.0 → 1.9.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.
- package/dist/functions.d.ts +1 -0
- package/dist/functions.js +22 -1
- package/package.json +1 -1
package/dist/functions.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export declare function hasNft<BSName extends string = string>(service: Blockcha
|
|
|
6
6
|
export declare function hasExplorerService<BSName extends string = string>(service: BlockchainService<BSName>): service is BlockchainService<BSName> & BSWithExplorerService;
|
|
7
7
|
export declare function hasLedger<BSName extends string = string>(service: BlockchainService<BSName>): service is BlockchainService<BSName> & BSWithLedger<BSName>;
|
|
8
8
|
export declare function waitForTransaction<BSName extends string = string>(service: BlockchainService<BSName>, txId: string): Promise<boolean>;
|
|
9
|
+
export declare function waitForAccountTransaction<BSName extends string = string>(service: BlockchainService<BSName>, txId: string, account: Account<BSName>): Promise<boolean>;
|
|
9
10
|
export declare function fetchAccountsForBlockchainServices<BSName extends string = string>(blockchainServices: BlockchainService<BSName>[], getAccountCallback: (service: BlockchainService<BSName>, index: number) => Promise<Account<BSName>>): Promise<Map<BSName, Account<BSName>[]>>;
|
package/dist/functions.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.fetchAccountsForBlockchainServices = exports.waitForTransaction = exports.hasLedger = exports.hasExplorerService = exports.hasNft = exports.isCalculableFee = exports.isClaimable = exports.hasNameService = void 0;
|
|
12
|
+
exports.fetchAccountsForBlockchainServices = exports.waitForAccountTransaction = exports.waitForTransaction = exports.hasLedger = exports.hasExplorerService = exports.hasNft = exports.isCalculableFee = exports.isClaimable = exports.hasNameService = void 0;
|
|
13
13
|
function hasNameService(service) {
|
|
14
14
|
return 'resolveNameServiceDomain' in service && 'validateNameServiceDomainFormat' in service;
|
|
15
15
|
}
|
|
@@ -57,6 +57,27 @@ function waitForTransaction(service, txId) {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
exports.waitForTransaction = waitForTransaction;
|
|
60
|
+
function waitForAccountTransaction(service, txId, account) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const maxAttempts = 10;
|
|
63
|
+
let attempts = 1;
|
|
64
|
+
do {
|
|
65
|
+
yield wait(60000);
|
|
66
|
+
try {
|
|
67
|
+
const response = yield service.blockchainDataService.getTransactionsByAddress({ address: account.address });
|
|
68
|
+
const isTransactionConfirmed = response.transactions.some(transaction => transaction.hash === txId);
|
|
69
|
+
if (isTransactionConfirmed)
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
catch (_a) {
|
|
73
|
+
// Empty block
|
|
74
|
+
}
|
|
75
|
+
attempts++;
|
|
76
|
+
} while (attempts < maxAttempts);
|
|
77
|
+
return false;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
exports.waitForAccountTransaction = waitForAccountTransaction;
|
|
60
81
|
function fetchAccountsForBlockchainServices(blockchainServices, getAccountCallback) {
|
|
61
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
83
|
const accountsByBlockchainService = new Map();
|