@cityofzion/bs-ethereum 2.12.1 → 2.12.3

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.
@@ -51,6 +51,7 @@ const MoralisEDSEthereum_1 = require("./services/exchange-data/MoralisEDSEthereu
51
51
  const GhostMarketNDSEthereum_1 = require("./services/nft-data/GhostMarketNDSEthereum");
52
52
  const BlockscoutESEthereum_1 = require("./services/explorer/BlockscoutESEthereum");
53
53
  const RpcBDSEthereum_1 = require("./services/blockchain-data/RpcBDSEthereum");
54
+ const BSEthereumTokenHelper_1 = require("./helpers/BSEthereumTokenHelper");
54
55
  class BSEthereum {
55
56
  constructor(name, network, getLedgerTransport) {
56
57
  _BSEthereum_instances.add(this);
@@ -226,7 +227,7 @@ _BSEthereum_instances = new WeakSet(), _BSEthereum_buildTransferParams = functio
226
227
  let transactionParams = {
227
228
  type: 2,
228
229
  };
229
- const isNative = BSEthereumHelper_1.BSEthereumHelper.normalizeHash(this.feeToken.hash) === BSEthereumHelper_1.BSEthereumHelper.normalizeHash(intent.tokenHash);
230
+ const isNative = BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(this.feeToken)(intent.tokenHash);
230
231
  if (isNative) {
231
232
  transactionParams.to = intent.receiverAddress;
232
233
  transactionParams.value = amount;
@@ -217,4 +217,5 @@ BSEthereumConstants.TESTNET_NETWORKS = [
217
217
  },
218
218
  ];
219
219
  BSEthereumConstants.ALL_NETWORKS = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
220
+ // If tou change this, make sure to update the tests accordingly
220
221
  BSEthereumConstants.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
@@ -10,7 +10,4 @@ export declare class BSEthereumHelper {
10
10
  static getNativeSymbol(network: Network<BSEthereumNetworkId>): string;
11
11
  static getRpcList(network: Network<BSEthereumNetworkId>): string[];
12
12
  static isMainnet(network: Network<BSEthereumNetworkId>): boolean;
13
- static normalizeHash(hash: string): string;
14
- static wait(duration: number): Promise<void>;
15
- static retry<T = any>(callback: () => Promise<T>): Promise<T>;
16
13
  }
@@ -1,21 +1,12 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.BSEthereumHelper = void 0;
13
- const blockchain_service_1 = require("@cityofzion/blockchain-service");
14
4
  const BSEthereumConstants_1 = require("../constants/BSEthereumConstants");
5
+ const BSEthereumTokenHelper_1 = require("./BSEthereumTokenHelper");
15
6
  class BSEthereumHelper {
16
7
  static getNativeAsset(network) {
17
8
  const symbol = this.getNativeSymbol(network);
18
- return { symbol, name: symbol, decimals: 18, hash: '-' };
9
+ return BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({ symbol, name: symbol, decimals: 18, hash: '0x' });
19
10
  }
20
11
  static getNativeSymbol(network) {
21
12
  var _a;
@@ -28,32 +19,5 @@ class BSEthereumHelper {
28
19
  static isMainnet(network) {
29
20
  return BSEthereumConstants_1.BSEthereumConstants.MAINNET_NETWORK_IDS.includes(network.id);
30
21
  }
31
- static normalizeHash(hash) {
32
- return (0, blockchain_service_1.normalizeHash)(hash);
33
- }
34
- static wait(duration) {
35
- return new Promise(resolve => {
36
- setTimeout(resolve, duration);
37
- });
38
- }
39
- static retry(callback) {
40
- // eslint-disable-next-line no-async-promise-executor
41
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
42
- // Wait up to 5 seconds
43
- for (let i = 0; i < 50; i++) {
44
- try {
45
- const result = yield callback();
46
- return resolve(result);
47
- }
48
- catch (error) {
49
- if (error.id !== 'TransportLocked') {
50
- return reject(error);
51
- }
52
- }
53
- yield this.wait(100);
54
- }
55
- return reject(new Error('timeout'));
56
- }));
57
- }
58
22
  }
59
23
  exports.BSEthereumHelper = BSEthereumHelper;
@@ -0,0 +1,4 @@
1
+ import { BSTokenHelper } from '@cityofzion/blockchain-service';
2
+ export declare class BSEthereumTokenHelper extends BSTokenHelper {
3
+ static normalizeHash(hash: string): string;
4
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BSEthereumTokenHelper = void 0;
4
+ const blockchain_service_1 = require("@cityofzion/blockchain-service");
5
+ const ethers_1 = require("ethers");
6
+ class BSEthereumTokenHelper extends blockchain_service_1.BSTokenHelper {
7
+ static normalizeHash(hash) {
8
+ let fixedHash = blockchain_service_1.BSTokenHelper.normalizeHash(hash);
9
+ try {
10
+ fixedHash = ethers_1.ethers.utils.getAddress(fixedHash); // Normalize to checksum address
11
+ }
12
+ catch (_a) {
13
+ /* empty */
14
+ }
15
+ return fixedHash;
16
+ }
17
+ }
18
+ exports.BSEthereumTokenHelper = BSEthereumTokenHelper;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './BSEthereum';
2
2
  export * from './helpers/BSEthereumHelper';
3
+ export * from './helpers/BSEthereumTokenHelper';
3
4
  export * from './constants/BSEthereumConstants';
4
5
  export * from './services/blockchain-data/MoralisBDSEthereum';
5
6
  export * from './services/blockchain-data/DoraBDSEthereum';
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BSEthereum"), exports);
18
18
  __exportStar(require("./helpers/BSEthereumHelper"), exports);
19
+ __exportStar(require("./helpers/BSEthereumTokenHelper"), exports);
19
20
  __exportStar(require("./constants/BSEthereumConstants"), exports);
20
21
  __exportStar(require("./services/blockchain-data/MoralisBDSEthereum"), exports);
21
22
  __exportStar(require("./services/blockchain-data/DoraBDSEthereum"), exports);
@@ -61,7 +61,8 @@ class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
61
61
  const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSEthereum_explorerService, "f").getTxTemplateUrl();
62
62
  const nftTemplateUrl = __classPrivateFieldGet(this, _DoraBDSEthereum_explorerService, "f").getNftTemplateUrl();
63
63
  const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSEthereum_explorerService, "f").getContractTemplateUrl();
64
- const itemPromises = items.map((item) => __awaiter(this, void 0, void 0, function* () {
64
+ const itemPromises = items.map((_c) => __awaiter(this, void 0, void 0, function* () {
65
+ var { networkFeeAmount, systemFeeAmount } = _c, item = __rest(_c, ["networkFeeAmount", "systemFeeAmount"]);
65
66
  const txId = item.transactionID;
66
67
  const newItem = {
67
68
  txId,
@@ -70,18 +71,22 @@ class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
70
71
  date: item.date,
71
72
  invocationCount: item.invocationCount,
72
73
  notificationCount: item.notificationCount,
73
- networkFeeAmount: (0, blockchain_service_1.formatNumber)(item.networkFeeAmount, nativeToken.decimals),
74
- systemFeeAmount: (0, blockchain_service_1.formatNumber)(item.systemFeeAmount, nativeToken.decimals),
74
+ networkFeeAmount: networkFeeAmount
75
+ ? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: nativeToken.decimals })
76
+ : undefined,
77
+ systemFeeAmount: systemFeeAmount
78
+ ? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: nativeToken.decimals })
79
+ : undefined,
75
80
  events: [],
76
81
  };
77
82
  const eventPromises = item.events.map((event) => __awaiter(this, void 0, void 0, function* () {
78
- var _c, _d, _e, _f, _g, _h;
83
+ var _d, _e, _f, _g, _h, _j;
79
84
  let nftEvent;
80
85
  let assetEvent;
81
86
  const { methodName, tokenID: tokenId, contractHash: hash } = event;
82
- const from = (_c = event.from) !== null && _c !== void 0 ? _c : undefined;
83
- const to = (_d = event.to) !== null && _d !== void 0 ? _d : undefined;
84
- const standard = (_g = (_f = (_e = event.supportedStandards) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.toLowerCase()) !== null && _g !== void 0 ? _g : '';
87
+ const from = (_d = event.from) !== null && _d !== void 0 ? _d : undefined;
88
+ const to = (_e = event.to) !== null && _e !== void 0 ? _e : undefined;
89
+ const standard = (_h = (_g = (_f = event.supportedStandards) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.toLowerCase()) !== null && _h !== void 0 ? _h : '';
85
90
  const isErc1155 = __classPrivateFieldGet(this, _DoraBDSEthereum_supportedErc1155Standards, "f").includes(standard);
86
91
  const isErc721 = __classPrivateFieldGet(this, _DoraBDSEthereum_supportedErc721Standards, "f").includes(standard);
87
92
  const isErc20 = __classPrivateFieldGet(this, _DoraBDSEthereum_supportedErc20Standards, "f").includes(standard);
@@ -94,7 +99,7 @@ class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
94
99
  const nftUrl = hash ? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{hash}', hash).replace('{tokenId}', tokenId) : undefined;
95
100
  nftEvent = {
96
101
  eventType: 'nft',
97
- amount: '0',
102
+ amount: undefined,
98
103
  methodName,
99
104
  from,
100
105
  fromUrl,
@@ -112,10 +117,11 @@ class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
112
117
  }
113
118
  else {
114
119
  const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(hash));
115
- const amount = (0, blockchain_service_1.formatNumber)(event.amount, (_h = token === null || token === void 0 ? void 0 : token.decimals) !== null && _h !== void 0 ? _h : event.tokenDecimals);
116
120
  assetEvent = {
117
121
  eventType: 'token',
118
- amount,
122
+ amount: event.amount
123
+ ? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_j = token === null || token === void 0 ? void 0 : token.decimals) !== null && _j !== void 0 ? _j : event.tokenDecimals })
124
+ : undefined,
119
125
  methodName,
120
126
  from,
121
127
  fromUrl,
@@ -32,6 +32,7 @@ const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
32
32
  const ERC20_1 = require("../../assets/abis/ERC20");
33
33
  const dora_ts_1 = require("@cityofzion/dora-ts");
34
34
  const DoraBDSEthereum_1 = require("./DoraBDSEthereum");
35
+ const BSEthereumTokenHelper_1 = require("../../helpers/BSEthereumTokenHelper");
35
36
  class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
36
37
  static getClient(network) {
37
38
  return axios_1.default.create({
@@ -76,12 +77,12 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
76
77
  return;
77
78
  balances.push({
78
79
  amount: ethers_1.ethers.utils.formatUnits(balance.balance, balance.decimals),
79
- token: {
80
+ token: BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({
80
81
  decimals: balance.decimals,
81
82
  hash: balance.token_address,
82
83
  name: (_a = balance.name) !== null && _a !== void 0 ? _a : '',
83
84
  symbol: balance.symbol,
84
- },
85
+ }),
85
86
  });
86
87
  });
87
88
  return balances;
@@ -96,7 +97,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
96
97
  return _super.getTokenInfo.call(this, hash);
97
98
  }
98
99
  const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
99
- if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(nativeAsset.hash) === BSEthereumHelper_1.BSEthereumHelper.normalizeHash(hash))
100
+ if (BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(nativeAsset)({ hash }))
100
101
  return nativeAsset;
101
102
  if (this._tokenCache.has(hash)) {
102
103
  return this._tokenCache.get(hash);
@@ -108,12 +109,12 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
108
109
  },
109
110
  });
110
111
  const data = response.data[0];
111
- const token = {
112
+ const token = BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({
112
113
  decimals: Number(data.decimals),
113
114
  symbol: data.symbol,
114
115
  hash,
115
116
  name: data.name,
116
- };
117
+ });
117
118
  this._tokenCache.set(hash, token);
118
119
  return token;
119
120
  });
@@ -223,12 +224,12 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
223
224
  from: transfer.from_address,
224
225
  to: transfer.to_address,
225
226
  type: 'token',
226
- token: {
227
+ token: BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({
227
228
  decimals: Number(transfer.token_decimals),
228
229
  hash: transfer.address,
229
230
  name: transfer.token_name,
230
231
  symbol: transfer.token_symbol,
231
- },
232
+ }),
232
233
  contractHash: transfer.address,
233
234
  });
234
235
  });
@@ -13,6 +13,7 @@ exports.RpcBDSEthereum = void 0;
13
13
  const ethers_1 = require("ethers");
14
14
  const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
15
15
  const ERC20_1 = require("../../assets/abis/ERC20");
16
+ const BSEthereumTokenHelper_1 = require("../../helpers/BSEthereumTokenHelper");
16
17
  class RpcBDSEthereum {
17
18
  constructor(network) {
18
19
  this._tokenCache = new Map();
@@ -37,7 +38,7 @@ class RpcBDSEthereum {
37
38
  {
38
39
  type: 'token',
39
40
  amount: ethers_1.ethers.utils.formatEther(transaction.value),
40
- contractHash: '-',
41
+ contractHash: token.hash,
41
42
  from: transaction.from,
42
43
  to: transaction.to,
43
44
  token,
@@ -70,7 +71,7 @@ class RpcBDSEthereum {
70
71
  getTokenInfo(hash) {
71
72
  return __awaiter(this, void 0, void 0, function* () {
72
73
  const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
73
- if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(nativeAsset.hash) === BSEthereumHelper_1.BSEthereumHelper.normalizeHash(hash))
74
+ if (BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(nativeAsset)({ hash }))
74
75
  return nativeAsset;
75
76
  if (this._tokenCache.has(hash)) {
76
77
  return this._tokenCache.get(hash);
@@ -79,12 +80,12 @@ class RpcBDSEthereum {
79
80
  const contract = new ethers_1.ethers.Contract(hash, ERC20_1.ERC20_ABI, provider);
80
81
  const decimals = yield contract.decimals();
81
82
  const symbol = yield contract.symbol();
82
- const token = {
83
+ const token = BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({
83
84
  decimals,
84
85
  symbol,
85
86
  hash,
86
87
  name: symbol,
87
- };
88
+ });
88
89
  this._tokenCache.set(hash, token);
89
90
  return token;
90
91
  });
@@ -26,6 +26,7 @@ const blockchain_service_1 = require("@cityofzion/blockchain-service");
26
26
  const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
27
27
  const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
28
28
  const MoralisBDSEthereum_1 = require("../blockchain-data/MoralisBDSEthereum");
29
+ const BSEthereumTokenHelper_1 = require("../../helpers/BSEthereumTokenHelper");
29
30
  class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
30
31
  constructor(network, blockchainDataService) {
31
32
  super();
@@ -81,9 +82,7 @@ class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
81
82
  });
82
83
  data.forEach(item => {
83
84
  let token;
84
- if (wrappedNativeToken &&
85
- BSEthereumHelper_1.BSEthereumHelper.normalizeHash(item.tokenAddress) ===
86
- BSEthereumHelper_1.BSEthereumHelper.normalizeHash(wrappedNativeToken.hash)) {
85
+ if (wrappedNativeToken && BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(wrappedNativeToken)(item.tokenAddress)) {
87
86
  token = nativeToken;
88
87
  }
89
88
  else {
@@ -111,7 +110,7 @@ class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
111
110
  throw new Error('Exchange is not supported on this network');
112
111
  const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _MoralisEDSEthereum_network, "f"));
113
112
  let token;
114
- if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(params.token.hash) === BSEthereumHelper_1.BSEthereumHelper.normalizeHash(nativeToken.hash)) {
113
+ if (BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(nativeToken)(params.token)) {
115
114
  token = yield __classPrivateFieldGet(this, _MoralisEDSEthereum_instances, "m", _MoralisEDSEthereum_getWrappedNativeToken).call(this);
116
115
  }
117
116
  else {
@@ -150,6 +149,6 @@ _MoralisEDSEthereum_network = new WeakMap(), _MoralisEDSEthereum_blockchainDataS
150
149
  const localWrappedHash = BSEthereumConstants_1.BSEthereumConstants.NATIVE_WRAPPED_HASH_BY_NETWORK_ID[__classPrivateFieldGet(this, _MoralisEDSEthereum_network, "f").id];
151
150
  if (!localWrappedHash)
152
151
  throw new Error('Wrapper token not found');
153
- return Object.assign(Object.assign({}, nativeToken), { symbol: wrappedSymbol, hash: localWrappedHash });
152
+ return BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken(Object.assign(Object.assign({}, nativeToken), { symbol: wrappedSymbol, hash: localWrappedHash }));
154
153
  });
155
154
  };
@@ -14,6 +14,7 @@ var _BlockscoutESEthereum_instances, _BlockscoutESEthereum_network, _BlockscoutE
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.BlockscoutESEthereum = void 0;
16
16
  const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
17
+ const BSEthereumTokenHelper_1 = require("../../helpers/BSEthereumTokenHelper");
17
18
  const DEFAULT_BASE_URL_BY_NETWORK_ID = {
18
19
  [BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID]: 'https://eth.blockscout.com',
19
20
  '10': 'https://optimism.blockscout.com',
@@ -35,15 +36,15 @@ class BlockscoutESEthereum {
35
36
  }
36
37
  buildTransactionUrl(hash) {
37
38
  const baseURL = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
38
- return `${baseURL}/tx/${hash}`;
39
+ return `${baseURL}/tx/${BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeHash(hash)}`;
39
40
  }
40
41
  buildContractUrl(contractHash) {
41
42
  const baseURL = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
42
- return `${baseURL}/address/${contractHash}`;
43
+ return `${baseURL}/address/${BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeHash(contractHash)}`;
43
44
  }
44
45
  buildNftUrl(params) {
45
46
  const baseURL = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
46
- return `${baseURL}/token/${params.contractHash}/instance/${params.tokenId}`;
47
+ return `${baseURL}/token/${BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeHash(params.contractHash)}/instance/${params.tokenId}`;
47
48
  }
48
49
  getAddressTemplateUrl() {
49
50
  try {
@@ -53,7 +53,9 @@ const hw_app_eth_1 = __importStar(require("@ledgerhq/hw-app-eth"));
53
53
  const ethers_1 = require("ethers");
54
54
  const properties_1 = require("@ethersproject/properties");
55
55
  const events_1 = __importDefault(require("events"));
56
- const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
56
+ const shouldRetry = (error) => {
57
+ return (error === null || error === void 0 ? void 0 : error.id) !== 'TransportLocked';
58
+ };
57
59
  class EthersLedgerSigner extends ethers_1.Signer {
58
60
  constructor(transport, bip44Path, provider, emitter) {
59
61
  super();
@@ -72,7 +74,7 @@ class EthersLedgerSigner extends ethers_1.Signer {
72
74
  }
73
75
  getAddress() {
74
76
  return __awaiter(this, void 0, void 0, function* () {
75
- const { address } = yield BSEthereumHelper_1.BSEthereumHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").getAddress(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f")));
77
+ const { address } = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").getAddress(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f")), { shouldRetry });
76
78
  return address;
77
79
  });
78
80
  }
@@ -84,7 +86,7 @@ class EthersLedgerSigner extends ethers_1.Signer {
84
86
  message = ethers_1.ethers.utils.toUtf8Bytes(message);
85
87
  }
86
88
  (_a = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _a === void 0 ? void 0 : _a.emit('getSignatureStart');
87
- const obj = yield BSEthereumHelper_1.BSEthereumHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signPersonalMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), ethers_1.ethers.utils.hexlify(message).substring(2)));
89
+ const obj = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signPersonalMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), ethers_1.ethers.utils.hexlify(message).substring(2)), { shouldRetry });
88
90
  (_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
89
91
  // Normalize the signature for Ethers
90
92
  obj.r = '0x' + obj.r;
@@ -107,7 +109,7 @@ class EthersLedgerSigner extends ethers_1.Signer {
107
109
  .substring(2);
108
110
  const resolution = yield hw_app_eth_1.ledgerService.resolveTransaction(serializedUnsignedTransaction, {}, {});
109
111
  (_a = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _a === void 0 ? void 0 : _a.emit('getSignatureStart');
110
- const signature = yield BSEthereumHelper_1.BSEthereumHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signTransaction(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), serializedUnsignedTransaction, resolution));
112
+ const signature = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signTransaction(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), serializedUnsignedTransaction, resolution), { shouldRetry });
111
113
  (_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
112
114
  return ethers_1.ethers.utils.serializeTransaction(tx, {
113
115
  v: ethers_1.ethers.BigNumber.from('0x' + signature.v).toNumber(),
@@ -137,12 +139,14 @@ class EthersLedgerSigner extends ethers_1.Signer {
137
139
  (_a = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _a === void 0 ? void 0 : _a.emit('getSignatureStart');
138
140
  let obj;
139
141
  try {
140
- obj = yield BSEthereumHelper_1.BSEthereumHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signEIP712Message(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), payload));
142
+ obj = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signEIP712Message(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), payload), {
143
+ shouldRetry,
144
+ });
141
145
  }
142
146
  catch (_d) {
143
147
  const domainSeparatorHex = ethers_1.ethers.utils._TypedDataEncoder.hashDomain(payload.domain);
144
148
  const hashStructMessageHex = ethers_1.ethers.utils._TypedDataEncoder.hashStruct(payload.primaryType, types, payload.message);
145
- obj = yield BSEthereumHelper_1.BSEthereumHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signEIP712HashedMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), domainSeparatorHex, hashStructMessageHex));
149
+ obj = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signEIP712HashedMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), domainSeparatorHex, hashStructMessageHex), { shouldRetry });
146
150
  }
147
151
  (_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
148
152
  // Normalize the signature for Ethers
@@ -179,7 +183,7 @@ class EthersLedgerServiceEthereum {
179
183
  return __awaiter(this, void 0, void 0, function* () {
180
184
  const ledgerApp = new hw_app_eth_1.default(transport);
181
185
  const bip44Path = __classPrivateFieldGet(this, _EthersLedgerServiceEthereum_blockchainService, "f").bip44DerivationPath.replace('?', index.toString());
182
- const { publicKey, address } = yield BSEthereumHelper_1.BSEthereumHelper.retry(() => ledgerApp.getAddress(bip44Path));
186
+ const { publicKey, address } = yield blockchain_service_1.BSUtilsHelper.retry(() => ledgerApp.getAddress(bip44Path), { shouldRetry });
183
187
  const publicKeyWithPrefix = '0x' + publicKey;
184
188
  return {
185
189
  address,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-ethereum",
3
- "version": "2.12.1",
3
+ "version": "2.12.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -22,7 +22,7 @@
22
22
  "@ethersproject/properties": "~5.7.0",
23
23
  "@cityofzion/dora-ts": "0.5.1",
24
24
  "date-fns": "~4.1.0",
25
- "@cityofzion/blockchain-service": "1.18.1"
25
+ "@cityofzion/blockchain-service": "1.19.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@ledgerhq/hw-transport-node-hid": "~6.28.5",