@cityofzion/blockchain-service 0.9.0 → 0.10.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.
@@ -55,7 +55,8 @@ class BSAggregator {
55
55
  const promises = this.blockchainServices.map((service) => __awaiter(this, void 0, void 0, function* () {
56
56
  let index = 0;
57
57
  const accounts = [];
58
- while (true) {
58
+ let hasError = false;
59
+ while (!hasError) {
59
60
  const generatedAccount = service.generateAccountFromMnemonic(mnemonic, index);
60
61
  if (skippedAddresses && skippedAddresses.find(address => address === generatedAccount.address)) {
61
62
  index++;
@@ -67,10 +68,10 @@ class BSAggregator {
67
68
  address: generatedAccount.address,
68
69
  });
69
70
  if (!totalCount || totalCount <= 0)
70
- break;
71
+ hasError = true;
71
72
  }
72
73
  catch (_a) {
73
- break;
74
+ hasError = true;
74
75
  }
75
76
  }
76
77
  accounts.push(generatedAccount);
@@ -1,7 +1,8 @@
1
- import { BlockchainService, BSCalculableFee, BSClaimable, BSWithExplorerService, BSWithNameService, BSWithNft } from './interfaces';
1
+ import { BlockchainService, BSCalculableFee, BSClaimable, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft } from './interfaces';
2
2
  export declare function hasNameService(service: BlockchainService): service is BlockchainService & BSWithNameService;
3
3
  export declare function isClaimable(service: BlockchainService): service is BlockchainService & BSClaimable;
4
4
  export declare function isCalculableFee(service: BlockchainService): service is BlockchainService & BSCalculableFee;
5
5
  export declare function hasNft(service: BlockchainService): service is BlockchainService & BSWithNft;
6
6
  export declare function hasExplorerService(service: BlockchainService): service is BlockchainService & BSWithExplorerService;
7
+ export declare function hasLedger(service: BlockchainService): service is BlockchainService & BSWithLedger;
7
8
  export declare function waitForTransaction(service: BlockchainService, txId: string): Promise<boolean>;
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.waitForTransaction = exports.hasExplorerService = exports.hasNft = exports.isCalculableFee = exports.isClaimable = exports.hasNameService = void 0;
12
+ 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
  }
@@ -30,6 +30,10 @@ function hasExplorerService(service) {
30
30
  return 'explorerService' in service;
31
31
  }
32
32
  exports.hasExplorerService = hasExplorerService;
33
+ function hasLedger(service) {
34
+ return 'ledgerService' in service;
35
+ }
36
+ exports.hasLedger = hasLedger;
33
37
  function wait(ms) {
34
38
  return new Promise(resolve => setTimeout(resolve, ms));
35
39
  }
@@ -43,7 +47,9 @@ function waitForTransaction(service, txId) {
43
47
  yield service.blockchainDataService.getTransaction(txId);
44
48
  return true;
45
49
  }
46
- catch (_a) { }
50
+ catch (_a) {
51
+ // Empty block
52
+ }
47
53
  attempts++;
48
54
  yield wait(waitMs);
49
55
  } while (attempts < maxAttempts);
@@ -1,7 +1,8 @@
1
+ import Transport from '@ledgerhq/hw-transport';
1
2
  export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
2
3
  export type Account = {
3
4
  key: string;
4
- type: 'wif' | 'privateKey';
5
+ type: 'wif' | 'privateKey' | 'publicKey';
5
6
  address: string;
6
7
  };
7
8
  export type AccountWithDerivationPath = Account & {
@@ -24,12 +25,19 @@ export type IntentTransferParam = {
24
25
  amount: string;
25
26
  tokenDecimals?: number;
26
27
  };
28
+ export type TransferParamWithLedger = {
29
+ isLedger: true;
30
+ ledgerTransport: Transport;
31
+ };
32
+ export type TransferParamWithoutLedger = {
33
+ isLedger?: false;
34
+ };
27
35
  export type TransferParam = {
28
36
  senderAccount: Account;
29
37
  intent: IntentTransferParam;
30
38
  tipIntent?: IntentTransferParam;
31
39
  priorityFee?: string;
32
- };
40
+ } & (TransferParamWithLedger | TransferParamWithoutLedger);
33
41
  export type TokenPricesResponse = {
34
42
  price: number;
35
43
  symbol: string;
@@ -76,6 +84,10 @@ export interface BSWithExplorerService {
76
84
  export interface BSWithNft {
77
85
  nftDataService: NftDataService;
78
86
  }
87
+ export interface BSWithLedger {
88
+ ledgerService: LedgerService;
89
+ generateAccountFromPublicKey(publicKey: string): Account;
90
+ }
79
91
  export type TransactionNotifications = {
80
92
  eventName: string;
81
93
  state: {
@@ -148,6 +160,10 @@ export interface NftResponse {
148
160
  id: string;
149
161
  contractHash: string;
150
162
  collectionName?: string;
163
+ creator: {
164
+ address: string;
165
+ name?: string;
166
+ };
151
167
  collectionImage?: string;
152
168
  symbol: string;
153
169
  image?: string;
@@ -181,3 +197,7 @@ export interface ExplorerService {
181
197
  buildTransactionUrl(hash: string): string;
182
198
  buildNftUrl(params: BuildNftUrlParams): string;
183
199
  }
200
+ export interface LedgerService {
201
+ getAddress(transport: Transport): Promise<string>;
202
+ getPublicKey(transport: Transport): Promise<string>;
203
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/blockchain-service",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -11,10 +11,18 @@
11
11
  ],
12
12
  "devDependencies": {
13
13
  "@types/node": "~20.2.5",
14
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
15
+ "@typescript-eslint/parser": "^6.5.0",
16
+ "eslint": "^8.48.0",
14
17
  "ts-node": "10.9.1",
15
18
  "typescript": "4.9.5"
16
19
  },
20
+ "dependencies": {
21
+ "@ledgerhq/hw-transport": "~6.30.5"
22
+ },
17
23
  "scripts": {
18
- "build": "tsc"
24
+ "build": "tsc",
25
+ "lint": "eslint .",
26
+ "format": "eslint --fix"
19
27
  }
20
28
  }