@cityofzion/blockchain-service 0.10.0 → 0.11.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 +6 -6
- package/dist/BSAggregator.js +34 -21
- package/dist/interfaces.d.ts +4 -9
- package/package.json +1 -1
- package/dist/exceptions.d.ts +0 -9
- package/dist/exceptions.js +0 -21
package/dist/BSAggregator.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { AccountWithDerivationPath, BlockchainService } from './interfaces';
|
|
1
|
+
import { AccountWithDerivationPath, BlockchainService, Network, PartialBy } from './interfaces';
|
|
2
2
|
export declare class BSAggregator<BSCustomName extends string = string, BSCustom extends BlockchainService<BSCustomName> = BlockchainService<BSCustomName>> {
|
|
3
|
+
#private;
|
|
3
4
|
readonly blockchainServicesByName: Record<BSCustomName, BSCustom>;
|
|
4
|
-
readonly blockchainServices: BlockchainService<BSCustomName>[];
|
|
5
5
|
constructor(blockchainServices: Record<BSCustomName, BSCustom>);
|
|
6
|
+
setNetwork(network: PartialBy<Network, 'url'>): void;
|
|
6
7
|
addBlockchain(name: BSCustomName, blockchain: BSCustom): void;
|
|
7
8
|
validateAddressAllBlockchains(address: string): boolean;
|
|
8
9
|
validateTextAllBlockchains(text: string): boolean;
|
|
9
10
|
validateKeyAllBlockchains(wif: string): boolean;
|
|
10
11
|
validateEncryptedAllBlockchains(keyOrJson: string): boolean;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getBlockchainByEncrypted(keyOrJson: string): BlockchainService<BSCustomName> | undefined;
|
|
12
|
+
getBlockchainNameByAddress(address: string): BSCustomName | undefined;
|
|
13
|
+
getBlockchainNameByKey(wif: string): BSCustomName | undefined;
|
|
14
|
+
getBlockchainNameByEncrypted(keyOrJson: string): BSCustomName | undefined;
|
|
15
15
|
generateAccountFromMnemonicAllBlockchains(mnemonic: string, skippedAddresses?: string[]): Promise<Map<BSCustomName, AccountWithDerivationPath[]>>;
|
|
16
16
|
}
|
package/dist/BSAggregator.js
CHANGED
|
@@ -8,51 +8,63 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _BSAggregator_blockchainServices;
|
|
11
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
24
|
exports.BSAggregator = void 0;
|
|
13
|
-
const exceptions_1 = require("./exceptions");
|
|
14
25
|
class BSAggregator {
|
|
15
26
|
constructor(blockchainServices) {
|
|
27
|
+
_BSAggregator_blockchainServices.set(this, void 0);
|
|
16
28
|
this.blockchainServicesByName = blockchainServices;
|
|
17
|
-
this
|
|
29
|
+
__classPrivateFieldSet(this, _BSAggregator_blockchainServices, Object.values(blockchainServices), "f");
|
|
30
|
+
}
|
|
31
|
+
setNetwork(network) {
|
|
32
|
+
__classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").forEach(bs => bs.setNetwork(network));
|
|
18
33
|
}
|
|
19
34
|
addBlockchain(name, blockchain) {
|
|
20
35
|
if (this.blockchainServicesByName[name])
|
|
21
|
-
throw new
|
|
36
|
+
throw new Error(`The blockchain ${name} already exist`);
|
|
22
37
|
this.blockchainServicesByName[name] = blockchain;
|
|
23
|
-
this.
|
|
38
|
+
__classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").push(blockchain);
|
|
24
39
|
}
|
|
25
40
|
validateAddressAllBlockchains(address) {
|
|
26
|
-
return this.
|
|
41
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => bs.validateAddress(address));
|
|
27
42
|
}
|
|
28
43
|
validateTextAllBlockchains(text) {
|
|
29
|
-
return this.
|
|
44
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => [bs.validateAddress(text), bs.validateEncrypted(text), bs.validateKey(text)].some(it => it === true));
|
|
30
45
|
}
|
|
31
46
|
validateKeyAllBlockchains(wif) {
|
|
32
|
-
return this.
|
|
47
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => bs.validateKey(wif));
|
|
33
48
|
}
|
|
34
49
|
validateEncryptedAllBlockchains(keyOrJson) {
|
|
35
|
-
return this.
|
|
36
|
-
}
|
|
37
|
-
getBlockchainByName(name) {
|
|
38
|
-
const service = this.blockchainServicesByName[name];
|
|
39
|
-
if (!service)
|
|
40
|
-
throw new exceptions_1.BlockchainNotFoundError(name);
|
|
41
|
-
return this.blockchainServicesByName[name];
|
|
50
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => bs.validateEncrypted(keyOrJson));
|
|
42
51
|
}
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
getBlockchainNameByAddress(address) {
|
|
53
|
+
var _a;
|
|
54
|
+
return (_a = __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").find(bs => bs.validateAddress(address))) === null || _a === void 0 ? void 0 : _a.blockchainName;
|
|
45
55
|
}
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
getBlockchainNameByKey(wif) {
|
|
57
|
+
var _a;
|
|
58
|
+
return (_a = __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").find(bs => bs.validateKey(wif))) === null || _a === void 0 ? void 0 : _a.blockchainName;
|
|
48
59
|
}
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
getBlockchainNameByEncrypted(keyOrJson) {
|
|
61
|
+
var _a;
|
|
62
|
+
return (_a = __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").find(bs => bs.validateEncrypted(keyOrJson))) === null || _a === void 0 ? void 0 : _a.blockchainName;
|
|
51
63
|
}
|
|
52
64
|
generateAccountFromMnemonicAllBlockchains(mnemonic, skippedAddresses) {
|
|
53
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
66
|
const mnemonicAccounts = new Map();
|
|
55
|
-
const promises = this.
|
|
67
|
+
const promises = __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").map((service) => __awaiter(this, void 0, void 0, function* () {
|
|
56
68
|
let index = 0;
|
|
57
69
|
const accounts = [];
|
|
58
70
|
let hasError = false;
|
|
@@ -85,3 +97,4 @@ class BSAggregator {
|
|
|
85
97
|
}
|
|
86
98
|
}
|
|
87
99
|
exports.BSAggregator = BSAggregator;
|
|
100
|
+
_BSAggregator_blockchainServices = new WeakMap();
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -25,19 +25,13 @@ export type IntentTransferParam = {
|
|
|
25
25
|
amount: string;
|
|
26
26
|
tokenDecimals?: number;
|
|
27
27
|
};
|
|
28
|
-
export type TransferParamWithLedger = {
|
|
29
|
-
isLedger: true;
|
|
30
|
-
ledgerTransport: Transport;
|
|
31
|
-
};
|
|
32
|
-
export type TransferParamWithoutLedger = {
|
|
33
|
-
isLedger?: false;
|
|
34
|
-
};
|
|
35
28
|
export type TransferParam = {
|
|
36
29
|
senderAccount: Account;
|
|
37
30
|
intent: IntentTransferParam;
|
|
38
31
|
tipIntent?: IntentTransferParam;
|
|
39
32
|
priorityFee?: string;
|
|
40
|
-
|
|
33
|
+
isLedger?: boolean;
|
|
34
|
+
};
|
|
41
35
|
export type TokenPricesResponse = {
|
|
42
36
|
price: number;
|
|
43
37
|
symbol: string;
|
|
@@ -72,7 +66,7 @@ export interface BSClaimable {
|
|
|
72
66
|
readonly claimToken: Token;
|
|
73
67
|
readonly burnToken: Token;
|
|
74
68
|
blockchainDataService: BlockchainDataService & BDSClaimable;
|
|
75
|
-
claim(account: Account): Promise<string>;
|
|
69
|
+
claim(account: Account, isLedger?: boolean): Promise<string>;
|
|
76
70
|
}
|
|
77
71
|
export interface BSWithNameService {
|
|
78
72
|
resolveNameServiceDomain(domainName: string): Promise<string>;
|
|
@@ -198,6 +192,7 @@ export interface ExplorerService {
|
|
|
198
192
|
buildNftUrl(params: BuildNftUrlParams): string;
|
|
199
193
|
}
|
|
200
194
|
export interface LedgerService {
|
|
195
|
+
getLedgerTransport?: (account: Account) => Promise<Transport>;
|
|
201
196
|
getAddress(transport: Transport): Promise<string>;
|
|
202
197
|
getPublicKey(transport: Transport): Promise<string>;
|
|
203
198
|
}
|
package/package.json
CHANGED
package/dist/exceptions.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class BlockchainAlreadyExistError extends Error {
|
|
2
|
-
constructor(blockchainName: string);
|
|
3
|
-
}
|
|
4
|
-
export declare class InvalidBlockchainServiceError extends Error {
|
|
5
|
-
constructor(message?: string);
|
|
6
|
-
}
|
|
7
|
-
export declare class BlockchainNotFoundError extends Error {
|
|
8
|
-
constructor(blockchainName: string);
|
|
9
|
-
}
|
package/dist/exceptions.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlockchainNotFoundError = exports.InvalidBlockchainServiceError = exports.BlockchainAlreadyExistError = void 0;
|
|
4
|
-
class BlockchainAlreadyExistError extends Error {
|
|
5
|
-
constructor(blockchainName) {
|
|
6
|
-
super(`The blockchain ${blockchainName} already exist`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.BlockchainAlreadyExistError = BlockchainAlreadyExistError;
|
|
10
|
-
class InvalidBlockchainServiceError extends Error {
|
|
11
|
-
constructor(message) {
|
|
12
|
-
super(`Invalid blockchainServices => ${message}`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.InvalidBlockchainServiceError = InvalidBlockchainServiceError;
|
|
16
|
-
class BlockchainNotFoundError extends Error {
|
|
17
|
-
constructor(blockchainName) {
|
|
18
|
-
super(`The blockchain ${blockchainName} not found`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.BlockchainNotFoundError = BlockchainNotFoundError;
|