@cityofzion/blockchain-service 1.13.3 → 1.15.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/BSAggregator.d.ts +1 -1
- package/dist/BSAggregator.js +7 -2
- package/dist/functions.d.ts +1 -0
- package/dist/functions.js +23 -2
- package/dist/interfaces.d.ts +4 -1
- package/package.json +1 -1
package/dist/BSAggregator.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare class BSAggregator<BSName extends string = string> {
|
|
|
10
10
|
getBlockchainNameByAddress(address: string): BSName[];
|
|
11
11
|
getBlockchainNameByKey(wif: string): BSName[];
|
|
12
12
|
getBlockchainNameByEncrypted(keyOrJson: string): BSName[];
|
|
13
|
-
generateAccountsFromMnemonic(mnemonic: string): Promise<Map<BSName, Account<BSName>[]>>;
|
|
13
|
+
generateAccountsFromMnemonic(mnemonic: string, untilIndex?: number): Promise<Map<BSName, Account<BSName>[]>>;
|
|
14
14
|
}
|
package/dist/BSAggregator.js
CHANGED
|
@@ -56,9 +56,14 @@ class BSAggregator {
|
|
|
56
56
|
getBlockchainNameByEncrypted(keyOrJson) {
|
|
57
57
|
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").filter(bs => bs.validateEncrypted(keyOrJson)).map(bs => bs.name);
|
|
58
58
|
}
|
|
59
|
-
generateAccountsFromMnemonic(mnemonic) {
|
|
59
|
+
generateAccountsFromMnemonic(mnemonic, untilIndex) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
|
|
61
|
+
if (untilIndex === undefined) {
|
|
62
|
+
return (0, functions_1.fetchAccountsForBlockchainServices)(__classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f"), (service, index) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
return service.generateAccountFromMnemonic(mnemonic, index);
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
return (0, functions_1.generateAccountUntilIndexForBlockchainService)(__classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f"), untilIndex, (service, index) => __awaiter(this, void 0, void 0, function* () {
|
|
62
67
|
return service.generateAccountFromMnemonic(mnemonic, index);
|
|
63
68
|
}));
|
|
64
69
|
});
|
package/dist/functions.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare function wait(ms: number): Promise<unknown>;
|
|
|
12
12
|
export declare function waitForTransaction<BSName extends string = string>(service: BlockchainService<BSName>, txId: string): Promise<boolean>;
|
|
13
13
|
export declare function waitForAccountTransaction<BSName extends string = string>(service: BlockchainService<BSName>, txId: string, account: Account<BSName>, maxAttempts?: number): Promise<boolean>;
|
|
14
14
|
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>[]>>;
|
|
15
|
+
export declare function generateAccountUntilIndexForBlockchainService<BSName extends string = string>(blockchainServices: BlockchainService<BSName>[], untilIndex: number, getAccountCallback: (service: BlockchainService<BSName>, index: number) => Promise<Account<BSName>>): Promise<Map<BSName, Account<BSName>[]>>;
|
|
15
16
|
export declare function normalizeHash(hash: string): string;
|
|
16
17
|
export declare function denormalizeHash(hash: string): string;
|
|
17
18
|
export declare function countDecimals(value: string | number): number;
|
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.formatNumber = exports.countDecimals = exports.denormalizeHash = exports.normalizeHash = exports.fetchAccountsForBlockchainServices = exports.waitForAccountTransaction = exports.waitForTransaction = exports.wait = exports.hasLedger = exports.hasExplorerService = exports.hasNft = exports.isCalculableFee = exports.isClaimable = exports.hasNameService = void 0;
|
|
12
|
+
exports.formatNumber = exports.countDecimals = exports.denormalizeHash = exports.normalizeHash = exports.generateAccountUntilIndexForBlockchainService = exports.fetchAccountsForBlockchainServices = exports.waitForAccountTransaction = exports.waitForTransaction = exports.wait = 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
|
}
|
|
@@ -107,11 +107,32 @@ function fetchAccountsForBlockchainServices(blockchainServices, getAccountCallba
|
|
|
107
107
|
}
|
|
108
108
|
accountsByBlockchainService.set(service.name, accounts);
|
|
109
109
|
}));
|
|
110
|
-
yield Promise.
|
|
110
|
+
yield Promise.allSettled(promises);
|
|
111
111
|
return accountsByBlockchainService;
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
exports.fetchAccountsForBlockchainServices = fetchAccountsForBlockchainServices;
|
|
115
|
+
function generateAccountUntilIndexForBlockchainService(blockchainServices, untilIndex, getAccountCallback) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
if (untilIndex < 0) {
|
|
118
|
+
throw new Error('Invalid index');
|
|
119
|
+
}
|
|
120
|
+
const accountsByBlockchainService = new Map();
|
|
121
|
+
const promises = blockchainServices.map((service) => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
let index = 0;
|
|
123
|
+
const accounts = [];
|
|
124
|
+
while (index <= untilIndex) {
|
|
125
|
+
const generatedAccount = yield getAccountCallback(service, index);
|
|
126
|
+
accounts.push(generatedAccount);
|
|
127
|
+
index++;
|
|
128
|
+
}
|
|
129
|
+
accountsByBlockchainService.set(service.name, accounts);
|
|
130
|
+
}));
|
|
131
|
+
yield Promise.allSettled(promises);
|
|
132
|
+
return accountsByBlockchainService;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
exports.generateAccountUntilIndexForBlockchainService = generateAccountUntilIndexForBlockchainService;
|
|
115
136
|
function normalizeHash(hash) {
|
|
116
137
|
return hash.replace('0x', '').toLowerCase();
|
|
117
138
|
}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -226,7 +226,7 @@ export type GetLedgerTransport<BSName extends string = string> = (account: Accou
|
|
|
226
226
|
export interface LedgerService<BSName extends string = string> {
|
|
227
227
|
emitter: LedgerServiceEmitter;
|
|
228
228
|
getLedgerTransport?: GetLedgerTransport<BSName>;
|
|
229
|
-
getAccounts(transport: Transport): Promise<Account<BSName>[]>;
|
|
229
|
+
getAccounts(transport: Transport, untilIndex?: number): Promise<Account<BSName>[]>;
|
|
230
230
|
getAccount(transport: Transport, index: number): Promise<Account<BSName>>;
|
|
231
231
|
}
|
|
232
232
|
export type SwapServiceToken<BSName extends string = string> = {
|
|
@@ -240,6 +240,7 @@ export type SwapServiceToken<BSName extends string = string> = {
|
|
|
240
240
|
addressTemplateUrl?: string;
|
|
241
241
|
txTemplateUrl?: string;
|
|
242
242
|
network?: string;
|
|
243
|
+
hasExtraId: boolean;
|
|
243
244
|
};
|
|
244
245
|
export type SwapServiceLoadableValue<T> = {
|
|
245
246
|
loading: boolean;
|
|
@@ -259,6 +260,7 @@ export type SwapServiceEvents<BSName extends string = string> = {
|
|
|
259
260
|
tokenToUse: (token: SwapServiceLoadableValue<SwapServiceToken<BSName>>) => void | Promise<void>;
|
|
260
261
|
availableTokensToUse: (tokens: SwapServiceLoadableValue<SwapServiceToken<BSName>[]>) => void | Promise<void>;
|
|
261
262
|
addressToReceive: (account: SwapServiceValidateValue<string>) => void | Promise<void>;
|
|
263
|
+
extraIdToReceive: (extraIdToReceive: SwapServiceValidateValue<string>) => void;
|
|
262
264
|
amountToReceive: (amount: SwapServiceLoadableValue<string>) => void | Promise<void>;
|
|
263
265
|
tokenToReceive: (token: SwapServiceLoadableValue<SwapServiceToken<BSName>>) => void | Promise<void>;
|
|
264
266
|
availableTokensToReceive: (tokens: SwapServiceLoadableValue<SwapServiceToken<BSName>[]>) => void | Promise<void>;
|
|
@@ -285,6 +287,7 @@ export interface SwapService<BSName extends string = string> {
|
|
|
285
287
|
setAmountToUse(amount: string | null): Promise<void>;
|
|
286
288
|
setTokenToReceive(token: SwapServiceToken<BSName> | null): Promise<void>;
|
|
287
289
|
setAddressToReceive(address: string | null): Promise<void>;
|
|
290
|
+
setExtraIdToReceive(extraId: string | null): Promise<void>;
|
|
288
291
|
swap(): Promise<SwapServiceSwapResult>;
|
|
289
292
|
calculateFee(): Promise<string>;
|
|
290
293
|
}
|