@cityofzion/blockchain-service 0.9.1 → 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.
@@ -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
  }
@@ -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: {
@@ -185,3 +197,7 @@ export interface ExplorerService {
185
197
  buildTransactionUrl(hash: string): string;
186
198
  buildNftUrl(params: BuildNftUrlParams): string;
187
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.1",
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",
@@ -17,6 +17,9 @@
17
17
  "ts-node": "10.9.1",
18
18
  "typescript": "4.9.5"
19
19
  },
20
+ "dependencies": {
21
+ "@ledgerhq/hw-transport": "~6.30.5"
22
+ },
20
23
  "scripts": {
21
24
  "build": "tsc",
22
25
  "lint": "eslint .",