@cityofzion/bs-ethereum 2.3.0 → 2.4.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,6 @@
1
- import { Account, BSCalculableFee, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, ExplorerService, Network, NftDataService, Token, TransferParam } from '@cityofzion/blockchain-service';
1
+ import { Account, BSCalculableFee, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, ExplorerService, Network, NftDataService, Token, TransferParam, GetLedgerTransport } from '@cityofzion/blockchain-service';
2
2
  import { BSEthereumNetworkId } from './constants/BSEthereumConstants';
3
3
  import { EthersLedgerServiceEthereum } from './services/ledger/EthersLedgerServiceEthereum';
4
- import Transport from '@ledgerhq/hw-transport';
5
4
  export declare class BSEthereum<BSCustomName extends string = string> implements BlockchainService<BSCustomName, BSEthereumNetworkId>, BSWithNft, BSWithNameService, BSCalculableFee, BSWithLedger, BSWithExplorerService {
6
5
  #private;
7
6
  readonly blockchainName: BSCustomName;
@@ -14,7 +13,8 @@ export declare class BSEthereum<BSCustomName extends string = string> implements
14
13
  nftDataService: NftDataService;
15
14
  network: Network<BSEthereumNetworkId>;
16
15
  explorerService: ExplorerService;
17
- constructor(blockchainName: BSCustomName, network?: Network<BSEthereumNetworkId>, getLedgerTransport?: (account: Account) => Promise<Transport>);
16
+ constructor(blockchainName: BSCustomName, network?: Network<BSEthereumNetworkId>, getLedgerTransport?: GetLedgerTransport);
17
+ clone(): BSEthereum<BSCustomName>;
18
18
  setNetwork(network: Network<BSEthereumNetworkId>): void;
19
19
  validateAddress(address: string): boolean;
20
20
  validateEncrypted(json: string): boolean;
@@ -31,12 +31,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
32
  });
33
33
  };
34
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
35
+ if (kind === "m") throw new TypeError("Private method is not writable");
36
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
37
+ 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");
38
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
39
+ };
34
40
  var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
35
41
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
36
42
  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");
37
43
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
38
44
  };
39
- var _BSEthereum_instances, _BSEthereum_generateSigner, _BSEthereum_buildTransferParams, _BSEthereum_setTokens;
45
+ var _BSEthereum_instances, _BSEthereum_getLedgerTransport, _BSEthereum_generateSigner, _BSEthereum_buildTransferParams, _BSEthereum_setTokens;
40
46
  Object.defineProperty(exports, "__esModule", { value: true });
41
47
  exports.BSEthereum = void 0;
42
48
  const ethers_1 = require("ethers");
@@ -55,12 +61,17 @@ const BlockscoutESEthereum_1 = require("./services/explorer/BlockscoutESEthereum
55
61
  class BSEthereum {
56
62
  constructor(blockchainName, network, getLedgerTransport) {
57
63
  _BSEthereum_instances.add(this);
64
+ _BSEthereum_getLedgerTransport.set(this, void 0);
58
65
  network = network !== null && network !== void 0 ? network : BSEthereumConstants_1.BSEthereumConstants.DEFAULT_NETWORK;
59
66
  this.blockchainName = blockchainName;
60
67
  this.ledgerService = new EthersLedgerServiceEthereum_1.EthersLedgerServiceEthereum(this, getLedgerTransport);
68
+ __classPrivateFieldSet(this, _BSEthereum_getLedgerTransport, getLedgerTransport, "f");
61
69
  this.bip44DerivationPath = BSEthereumConstants_1.BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH;
62
70
  this.setNetwork(network);
63
71
  }
72
+ clone() {
73
+ return new BSEthereum(this.blockchainName, this.network, __classPrivateFieldGet(this, _BSEthereum_getLedgerTransport, "f"));
74
+ }
64
75
  setNetwork(network) {
65
76
  __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_setTokens).call(this, network);
66
77
  this.network = network;
@@ -146,6 +157,7 @@ class BSEthereum {
146
157
  const signer = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_generateSigner).call(this, param.senderAccount, param.isLedger);
147
158
  const sentTransactionHashes = [];
148
159
  for (const intent of param.intents) {
160
+ let transactionHash = '';
149
161
  try {
150
162
  const { transactionParams, gasPrice } = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_buildTransferParams).call(this, intent);
151
163
  let gasLimit;
@@ -156,11 +168,12 @@ class BSEthereum {
156
168
  gasLimit = BSEthereumConstants_1.BSEthereumConstants.DEFAULT_GAS_LIMIT;
157
169
  }
158
170
  const transaction = yield signer.sendTransaction(Object.assign(Object.assign({}, transactionParams), { gasLimit, maxPriorityFeePerGas: gasPrice, maxFeePerGas: gasPrice }));
159
- sentTransactionHashes.push(transaction.hash);
171
+ transactionHash = transaction.hash;
160
172
  }
161
173
  catch (_b) {
162
174
  /* empty */
163
175
  }
176
+ sentTransactionHashes.push(transactionHash);
164
177
  }
165
178
  return sentTransactionHashes;
166
179
  });
@@ -189,7 +202,7 @@ class BSEthereum {
189
202
  }
190
203
  }
191
204
  exports.BSEthereum = BSEthereum;
192
- _BSEthereum_instances = new WeakSet(), _BSEthereum_generateSigner = function _BSEthereum_generateSigner(account, isLedger) {
205
+ _BSEthereum_getLedgerTransport = new WeakMap(), _BSEthereum_instances = new WeakSet(), _BSEthereum_generateSigner = function _BSEthereum_generateSigner(account, isLedger) {
193
206
  return __awaiter(this, void 0, void 0, function* () {
194
207
  const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.network.url);
195
208
  if (isLedger) {
@@ -1,4 +1,4 @@
1
- import { Account, LedgerService, LedgerServiceEmitter } from '@cityofzion/blockchain-service';
1
+ import { Account, LedgerService, LedgerServiceEmitter, GetLedgerTransport } from '@cityofzion/blockchain-service';
2
2
  import Transport from '@ledgerhq/hw-transport';
3
3
  import { ethers, Signer } from 'ethers';
4
4
  import { TypedDataSigner } from '@ethersproject/abstract-signer';
@@ -15,8 +15,8 @@ export declare class EthersLedgerSigner extends Signer implements TypedDataSigne
15
15
  export declare class EthersLedgerServiceEthereum implements LedgerService {
16
16
  #private;
17
17
  emitter: LedgerServiceEmitter;
18
- getLedgerTransport?: (account: Account) => Promise<Transport>;
19
- constructor(blockchainService: BSEthereum, getLedgerTransport?: (account: Account) => Promise<Transport>);
18
+ getLedgerTransport?: GetLedgerTransport;
19
+ constructor(blockchainService: BSEthereum, getLedgerTransport?: GetLedgerTransport);
20
20
  getAccounts(transport: Transport): Promise<Account[]>;
21
21
  getAccount(transport: Transport, index: number): Promise<Account>;
22
22
  getSigner(transport: Transport, path: string, provider?: ethers.providers.Provider): EthersLedgerSigner;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-ethereum",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -20,7 +20,7 @@
20
20
  "@ledgerhq/hw-app-eth": "~6.35.7",
21
21
  "@ethersproject/abstract-signer": "~5.7.0",
22
22
  "@ethersproject/properties": "~5.7.0",
23
- "@cityofzion/blockchain-service": "1.4.0"
23
+ "@cityofzion/blockchain-service": "1.5.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@ledgerhq/hw-transport-node-hid": "~6.28.5",