@cityofzion/blockchain-service 1.0.0 → 1.0.2
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 +5 -6
- package/dist/BSAggregator.js +3 -9
- package/dist/interfaces.d.ts +4 -7
- package/package.json +1 -1
package/dist/BSAggregator.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { AccountWithDerivationPath, BlockchainService
|
|
2
|
-
export declare class BSAggregator<BSCustomName extends string = string, BSCustom extends BlockchainService<BSCustomName> = BlockchainService<BSCustomName>> {
|
|
1
|
+
import { AccountWithDerivationPath, BlockchainService } from './interfaces';
|
|
2
|
+
export declare class BSAggregator<BSCustomName extends string = string, BSCustom extends BlockchainService<BSCustomName, string> = BlockchainService<BSCustomName, string>> {
|
|
3
3
|
#private;
|
|
4
4
|
readonly blockchainServicesByName: Record<BSCustomName, BSCustom>;
|
|
5
5
|
constructor(blockchainServices: Record<BSCustomName, BSCustom>);
|
|
6
|
-
setNetwork(network: PartialNetwork): void;
|
|
7
6
|
addBlockchain(name: BSCustomName, blockchain: BSCustom): void;
|
|
8
7
|
validateAddressAllBlockchains(address: string): boolean;
|
|
9
8
|
validateTextAllBlockchains(text: string): boolean;
|
|
10
9
|
validateKeyAllBlockchains(wif: string): boolean;
|
|
11
10
|
validateEncryptedAllBlockchains(keyOrJson: string): boolean;
|
|
12
|
-
getBlockchainNameByAddress(address: string): BSCustomName
|
|
13
|
-
getBlockchainNameByKey(wif: string): BSCustomName
|
|
14
|
-
getBlockchainNameByEncrypted(keyOrJson: string): BSCustomName
|
|
11
|
+
getBlockchainNameByAddress(address: string): BSCustomName[];
|
|
12
|
+
getBlockchainNameByKey(wif: string): BSCustomName[];
|
|
13
|
+
getBlockchainNameByEncrypted(keyOrJson: string): BSCustomName[];
|
|
15
14
|
generateAccountFromMnemonicAllBlockchains(mnemonic: string, skippedAddresses?: string[]): Promise<Map<BSCustomName, AccountWithDerivationPath[]>>;
|
|
16
15
|
}
|
package/dist/BSAggregator.js
CHANGED
|
@@ -28,9 +28,6 @@ class BSAggregator {
|
|
|
28
28
|
this.blockchainServicesByName = blockchainServices;
|
|
29
29
|
__classPrivateFieldSet(this, _BSAggregator_blockchainServices, Object.values(blockchainServices), "f");
|
|
30
30
|
}
|
|
31
|
-
setNetwork(network) {
|
|
32
|
-
__classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").forEach(bs => bs.setNetwork(network));
|
|
33
|
-
}
|
|
34
31
|
addBlockchain(name, blockchain) {
|
|
35
32
|
if (this.blockchainServicesByName[name])
|
|
36
33
|
throw new Error(`The blockchain ${name} already exist`);
|
|
@@ -50,16 +47,13 @@ class BSAggregator {
|
|
|
50
47
|
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => bs.validateEncrypted(keyOrJson));
|
|
51
48
|
}
|
|
52
49
|
getBlockchainNameByAddress(address) {
|
|
53
|
-
|
|
54
|
-
return (_a = __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").find(bs => bs.validateAddress(address))) === null || _a === void 0 ? void 0 : _a.blockchainName;
|
|
50
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").filter(bs => bs.validateAddress(address)).map(bs => bs.blockchainName);
|
|
55
51
|
}
|
|
56
52
|
getBlockchainNameByKey(wif) {
|
|
57
|
-
|
|
58
|
-
return (_a = __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").find(bs => bs.validateKey(wif))) === null || _a === void 0 ? void 0 : _a.blockchainName;
|
|
53
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").filter(bs => bs.validateKey(wif)).map(bs => bs.blockchainName);
|
|
59
54
|
}
|
|
60
55
|
getBlockchainNameByEncrypted(keyOrJson) {
|
|
61
|
-
|
|
62
|
-
return (_a = __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").find(bs => bs.validateEncrypted(keyOrJson))) === null || _a === void 0 ? void 0 : _a.blockchainName;
|
|
56
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").filter(bs => bs.validateEncrypted(keyOrJson)).map(bs => bs.blockchainName);
|
|
63
57
|
}
|
|
64
58
|
generateAccountFromMnemonicAllBlockchains(mnemonic, skippedAddresses) {
|
|
65
59
|
return __awaiter(this, void 0, void 0, function* () {
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -14,16 +14,12 @@ export interface Token {
|
|
|
14
14
|
hash: string;
|
|
15
15
|
decimals: number;
|
|
16
16
|
}
|
|
17
|
+
export type NetworkId<T extends string = string> = T | (string & {});
|
|
17
18
|
export type Network<T extends string = string> = {
|
|
18
|
-
id: T
|
|
19
|
+
id: NetworkId<T>;
|
|
19
20
|
name: string;
|
|
20
21
|
url: string;
|
|
21
22
|
};
|
|
22
|
-
export type PartialNetwork<T extends string = string> = {
|
|
23
|
-
id: T;
|
|
24
|
-
name?: string;
|
|
25
|
-
url?: string;
|
|
26
|
-
};
|
|
27
23
|
export type IntentTransferParam = {
|
|
28
24
|
receiverAddress: string;
|
|
29
25
|
tokenHash: string;
|
|
@@ -45,7 +41,7 @@ export interface BlockchainService<BSCustomName extends string = string, BSAvail
|
|
|
45
41
|
blockchainDataService: BlockchainDataService;
|
|
46
42
|
tokens: Token[];
|
|
47
43
|
network: Network<BSAvailableNetworks>;
|
|
48
|
-
setNetwork: (partialNetwork:
|
|
44
|
+
setNetwork: (partialNetwork: Network<BSAvailableNetworks>) => void;
|
|
49
45
|
generateAccountFromMnemonic(mnemonic: string | string, index: number): AccountWithDerivationPath;
|
|
50
46
|
generateAccountFromKey(key: string): Account;
|
|
51
47
|
decrypt(keyOrJson: string, password: string): Promise<Account>;
|
|
@@ -218,6 +214,7 @@ export type BuildNftUrlParams = {
|
|
|
218
214
|
};
|
|
219
215
|
export interface ExplorerService {
|
|
220
216
|
buildTransactionUrl(hash: string): string;
|
|
217
|
+
buildContractUrl(contractHash: string): string;
|
|
221
218
|
buildNftUrl(params: BuildNftUrlParams): string;
|
|
222
219
|
}
|
|
223
220
|
export type LedgerServiceEmitter = TypedEmitter<{
|