@cityofzion/bs-ethereum 2.13.0 → 2.13.1

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,8 +1,8 @@
1
- import { Account, BSCalculableFee, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, ExplorerService, Network, NftDataService, Token, TransferParam, GetLedgerTransport } from '@cityofzion/blockchain-service';
1
+ import { Account, BSCalculableFee, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, ExplorerService, Network, NftDataService, Token, TransferParam, GetLedgerTransport, BSWithEncryption, ITokenService } from '@cityofzion/blockchain-service';
2
2
  import { ethers } from 'ethers';
3
3
  import { BSEthereumNetworkId } from './constants/BSEthereumConstants';
4
4
  import { EthersLedgerServiceEthereum } from './services/ledger/EthersLedgerServiceEthereum';
5
- export declare class BSEthereum<BSName extends string = string, NetworkId extends string = BSEthereumNetworkId> implements BlockchainService<BSName, NetworkId>, BSWithNft, BSWithNameService, BSCalculableFee<BSName>, BSWithLedger<BSName>, BSWithExplorerService {
5
+ export declare class BSEthereum<BSName extends string = string, NetworkId extends string = BSEthereumNetworkId> implements BlockchainService<BSName, NetworkId>, BSWithNft, BSWithNameService, BSCalculableFee<BSName>, BSWithLedger<BSName>, BSWithExplorerService, BSWithEncryption<BSName> {
6
6
  #private;
7
7
  readonly name: BSName;
8
8
  readonly bip44DerivationPath: string;
@@ -15,6 +15,7 @@ export declare class BSEthereum<BSName extends string = string, NetworkId extend
15
15
  nftDataService: NftDataService;
16
16
  network: Network<NetworkId>;
17
17
  explorerService: ExplorerService;
18
+ tokenService: ITokenService;
18
19
  constructor(name: BSName, network?: Network<NetworkId>, getLedgerTransport?: GetLedgerTransport<BSName>);
19
20
  generateSigner(account: Account<BSName>): Promise<ethers.Signer>;
20
21
  testNetwork(network: Network<NetworkId>): Promise<void>;
@@ -51,7 +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
+ const TokenServiceEthereum_1 = require("./services/token/TokenServiceEthereum");
55
55
  class BSEthereum {
56
56
  constructor(name, network, getLedgerTransport) {
57
57
  _BSEthereum_instances.add(this);
@@ -77,7 +77,8 @@ class BSEthereum {
77
77
  }
78
78
  testNetwork(network) {
79
79
  return __awaiter(this, void 0, void 0, function* () {
80
- const blockchainDataServiceClone = new RpcBDSEthereum_1.RpcBDSEthereum(network);
80
+ this.tokenService = new TokenServiceEthereum_1.TokenServiceEthereum();
81
+ const blockchainDataServiceClone = new RpcBDSEthereum_1.RpcBDSEthereum(network, this.tokenService);
81
82
  yield blockchainDataServiceClone.getBlockHeight();
82
83
  });
83
84
  }
@@ -85,9 +86,10 @@ class BSEthereum {
85
86
  __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_setTokens).call(this, network);
86
87
  this.network = network;
87
88
  this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network);
88
- this.explorerService = new BlockscoutESEthereum_1.BlockscoutESEthereum(network);
89
- this.exchangeDataService = new MoralisEDSEthereum_1.MoralisEDSEthereum(network, this.blockchainDataService);
90
- this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(network, this.nftDataService, this.explorerService);
89
+ this.explorerService = new BlockscoutESEthereum_1.BlockscoutESEthereum(network, this.tokenService);
90
+ this.exchangeDataService = new MoralisEDSEthereum_1.MoralisEDSEthereum(network, this.blockchainDataService, this.tokenService);
91
+ this.tokenService = new TokenServiceEthereum_1.TokenServiceEthereum();
92
+ this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(network, this.nftDataService, this.explorerService, this.tokenService);
91
93
  }
92
94
  validateAddress(address) {
93
95
  return ethers_1.ethers.utils.isAddress(address);
@@ -227,7 +229,7 @@ _BSEthereum_instances = new WeakSet(), _BSEthereum_buildTransferParams = functio
227
229
  let transactionParams = {
228
230
  type: 2,
229
231
  };
230
- const isNative = BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(this.feeToken)(intent.tokenHash);
232
+ const isNative = this.tokenService.predicateByHash(this.feeToken)(intent.tokenHash);
231
233
  if (isNative) {
232
234
  transactionParams.to = intent.receiverAddress;
233
235
  transactionParams.value = amount;
@@ -1,13 +1,14 @@
1
1
  import { Network } from '@cityofzion/blockchain-service';
2
2
  import { BSEthereumNetworkId } from '../constants/BSEthereumConstants';
3
+ import { TokenServiceEthereum } from '../services/token/TokenServiceEthereum';
3
4
  export declare class BSEthereumHelper {
5
+ static tokenService: TokenServiceEthereum;
4
6
  static getNativeAsset(network: Network<BSEthereumNetworkId>): {
5
7
  symbol: string;
6
8
  name: string;
7
9
  decimals: number;
8
10
  hash: string;
9
11
  };
10
- static getNativeSymbol(network: Network<BSEthereumNetworkId>): string;
11
12
  static getRpcList(network: Network<BSEthereumNetworkId>): string[];
12
13
  static isMainnet(network: Network<BSEthereumNetworkId>): boolean;
13
14
  }
@@ -2,15 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BSEthereumHelper = void 0;
4
4
  const BSEthereumConstants_1 = require("../constants/BSEthereumConstants");
5
- const BSEthereumTokenHelper_1 = require("./BSEthereumTokenHelper");
5
+ const TokenServiceEthereum_1 = require("../services/token/TokenServiceEthereum");
6
6
  class BSEthereumHelper {
7
7
  static getNativeAsset(network) {
8
- const symbol = this.getNativeSymbol(network);
9
- return BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({ symbol, name: symbol, decimals: 18, hash: '0x' });
10
- }
11
- static getNativeSymbol(network) {
12
8
  var _a;
13
- return (_a = BSEthereumConstants_1.BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : 'ETH';
9
+ const symbol = (_a = BSEthereumConstants_1.BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : 'ETH';
10
+ return { symbol, name: symbol, decimals: 18, hash: this.tokenService.normalizeHash('0x') };
14
11
  }
15
12
  static getRpcList(network) {
16
13
  var _a;
@@ -21,3 +18,4 @@ class BSEthereumHelper {
21
18
  }
22
19
  }
23
20
  exports.BSEthereumHelper = BSEthereumHelper;
21
+ BSEthereumHelper.tokenService = new TokenServiceEthereum_1.TokenServiceEthereum();
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './BSEthereum';
2
2
  export * from './helpers/BSEthereumHelper';
3
- export * from './helpers/BSEthereumTokenHelper';
4
3
  export * from './constants/BSEthereumConstants';
5
4
  export * from './services/blockchain-data/MoralisBDSEthereum';
6
5
  export * from './services/blockchain-data/DoraBDSEthereum';
@@ -10,5 +9,6 @@ export * from './services/explorer/BlockscoutESEthereum';
10
9
  export * from './services/ledger/EthersLedgerServiceEthereum';
11
10
  export * from './services/nft-data/GhostMarketNDSEthereum';
12
11
  export * from './services/nft-data/RpcNDSEthereum';
12
+ export * from './services/token/TokenServiceEthereum';
13
13
  export * from './assets/abis/ERC20';
14
14
  export * from './assets/abis/ERC721';
package/dist/index.js CHANGED
@@ -16,7 +16,6 @@ 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);
20
19
  __exportStar(require("./constants/BSEthereumConstants"), exports);
21
20
  __exportStar(require("./services/blockchain-data/MoralisBDSEthereum"), exports);
22
21
  __exportStar(require("./services/blockchain-data/DoraBDSEthereum"), exports);
@@ -26,5 +25,6 @@ __exportStar(require("./services/explorer/BlockscoutESEthereum"), exports);
26
25
  __exportStar(require("./services/ledger/EthersLedgerServiceEthereum"), exports);
27
26
  __exportStar(require("./services/nft-data/GhostMarketNDSEthereum"), exports);
28
27
  __exportStar(require("./services/nft-data/RpcNDSEthereum"), exports);
28
+ __exportStar(require("./services/token/TokenServiceEthereum"), exports);
29
29
  __exportStar(require("./assets/abis/ERC20"), exports);
30
30
  __exportStar(require("./assets/abis/ERC721"), exports);
@@ -1,12 +1,12 @@
1
1
  import { RpcBDSEthereum } from './RpcBDSEthereum';
2
- import { FullTransactionsByAddressParams, Network, NetworkId } from '@cityofzion/blockchain-service';
2
+ import { FullTransactionsByAddressParams, Network, NetworkId, TokenService } from '@cityofzion/blockchain-service';
3
3
  import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
4
4
  export declare class DoraBDSEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> extends RpcBDSEthereum {
5
5
  readonly _supportedErc721Standards: string[];
6
6
  readonly _supportedErc1155Standards: string[];
7
7
  readonly _supportedErc20Standards: string[];
8
8
  readonly _supportedFullTransactionsByAddressNetworks: BSNetworkId[];
9
- constructor(network: Network<BSNetworkId>, supportedFullTransactionsByAddressNetworks: BSNetworkId[]);
9
+ constructor(network: Network<BSNetworkId>, supportedFullTransactionsByAddressNetworks: BSNetworkId[], tokenService: TokenService);
10
10
  _validateFullTransactionsByAddressParams(params: Pick<FullTransactionsByAddressParams, 'address' | 'dateFrom' | 'dateTo'>): void;
11
11
  _validateGetFullTransactionsByAddressParams({ pageSize, ...params }: Pick<FullTransactionsByAddressParams, 'address' | 'dateFrom' | 'dateTo' | 'pageSize'>): void;
12
12
  }
@@ -16,8 +16,8 @@ const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
16
16
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
17
17
  const ethers_1 = require("ethers");
18
18
  class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
19
- constructor(network, supportedFullTransactionsByAddressNetworks) {
20
- super(network);
19
+ constructor(network, supportedFullTransactionsByAddressNetworks, tokenService) {
20
+ super(network, tokenService);
21
21
  this._supportedErc721Standards = ['erc721', 'erc-721'];
22
22
  this._supportedErc1155Standards = ['erc1155', 'erc-1155'];
23
23
  this._supportedErc20Standards = ['erc20', 'erc-20'];
@@ -1,4 +1,4 @@
1
- import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, NftDataService, ExplorerService, ExportTransactionsByAddressParams } from '@cityofzion/blockchain-service';
1
+ import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, NftDataService, ExplorerService, ExportTransactionsByAddressParams, TokenService } from '@cityofzion/blockchain-service';
2
2
  import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
3
3
  import { DoraBDSEthereum } from './DoraBDSEthereum';
4
4
  export declare class MoralisBDSEthereum extends DoraBDSEthereum {
@@ -7,7 +7,7 @@ export declare class MoralisBDSEthereum extends DoraBDSEthereum {
7
7
  static SUPPORTED_CHAINS: string[];
8
8
  static getClient(network: Network<BSEthereumNetworkId>): import("axios").AxiosInstance;
9
9
  static isSupported(network: Network<BSEthereumNetworkId>): boolean;
10
- constructor(network: Network<BSEthereumNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService);
10
+ constructor(network: Network<BSEthereumNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService, tokenService: TokenService);
11
11
  getBalance(address: string): Promise<BalanceResponse[]>;
12
12
  getTokenInfo(hash: string): Promise<Token>;
13
13
  getTransaction(hash: string): Promise<TransactionResponse>;
@@ -44,7 +44,6 @@ const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
44
44
  const ERC20_1 = require("../../assets/abis/ERC20");
45
45
  const dora_ts_1 = require("@cityofzion/dora-ts");
46
46
  const DoraBDSEthereum_1 = require("./DoraBDSEthereum");
47
- const BSEthereumTokenHelper_1 = require("../../helpers/BSEthereumTokenHelper");
48
47
  class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
49
48
  static getClient(network) {
50
49
  return axios_1.default.create({
@@ -57,13 +56,13 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
57
56
  static isSupported(network) {
58
57
  return MoralisBDSEthereum.SUPPORTED_CHAINS.includes(network.id);
59
58
  }
60
- constructor(network, nftDataService, explorerService) {
59
+ constructor(network, nftDataService, explorerService, tokenService) {
61
60
  super(network, [
62
61
  BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID,
63
62
  BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID,
64
63
  BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID,
65
64
  BSEthereumConstants_1.BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID,
66
- ]);
65
+ ], tokenService);
67
66
  _MoralisBDSEthereum_nftDataService.set(this, void 0);
68
67
  _MoralisBDSEthereum_explorerService.set(this, void 0);
69
68
  __classPrivateFieldSet(this, _MoralisBDSEthereum_nftDataService, nftDataService, "f");
@@ -93,7 +92,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
93
92
  return;
94
93
  balances.push({
95
94
  amount: ethers_1.ethers.utils.formatUnits(balance.balance, balance.decimals),
96
- token: BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({
95
+ token: this._tokenService.normalizeToken({
97
96
  decimals: balance.decimals,
98
97
  hash: balance.token_address,
99
98
  name: (_a = balance.name) !== null && _a !== void 0 ? _a : '',
@@ -113,7 +112,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
113
112
  return _super.getTokenInfo.call(this, hash);
114
113
  }
115
114
  const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
116
- if (BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(nativeAsset)({ hash }))
115
+ if (this._tokenService.predicateByHash(nativeAsset)({ hash }))
117
116
  return nativeAsset;
118
117
  if (this._tokenCache.has(hash)) {
119
118
  return this._tokenCache.get(hash);
@@ -125,7 +124,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
125
124
  },
126
125
  });
127
126
  const data = response.data[0];
128
- const token = BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({
127
+ const token = this._tokenService.normalizeToken({
129
128
  decimals: Number(data.decimals),
130
129
  symbol: data.symbol,
131
130
  hash,
@@ -180,12 +179,12 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
180
179
  type: 'token',
181
180
  });
182
181
  }
183
- const tokenId = (_d = log.decoded_event.params.find((param) => param.name === 'tokenId')) === null || _d === void 0 ? void 0 : _d.value;
184
- if (!tokenId)
182
+ const tokenHash = (_d = log.decoded_event.params.find((param) => param.name === 'tokenId')) === null || _d === void 0 ? void 0 : _d.value;
183
+ if (!tokenHash)
185
184
  return;
186
185
  transfers.push({
187
- contractHash,
188
- tokenId,
186
+ collectionHash: contractHash,
187
+ tokenHash,
189
188
  from,
190
189
  to,
191
190
  type: 'nft',
@@ -241,7 +240,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
241
240
  from: transfer.from_address,
242
241
  to: transfer.to_address,
243
242
  type: 'token',
244
- token: BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({
243
+ token: this._tokenService.normalizeToken({
245
244
  decimals: Number(transfer.token_decimals),
246
245
  hash: transfer.address,
247
246
  name: transfer.token_name,
@@ -252,8 +251,8 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
252
251
  });
253
252
  item.nft_transfers.forEach(transfer => {
254
253
  transfers.push({
255
- contractHash: transfer.token_address,
256
- tokenId: transfer.token_id,
254
+ collectionHash: transfer.token_address,
255
+ tokenHash: transfer.token_id,
257
256
  from: transfer.from_address,
258
257
  to: transfer.to_address,
259
258
  type: 'nft',
@@ -316,23 +315,25 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
316
315
  type: 'default',
317
316
  };
318
317
  const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
319
- var _e, _f, _g, _h, _j, _k;
318
+ var _e, _f, _g, _h, _j, _k, _l;
320
319
  let nftEvent;
321
320
  let assetEvent;
322
- const { methodName, tokenID: tokenId, contractHash: hash } = event;
321
+ const { methodName, tokenID: tokenHash, contractHash } = event;
323
322
  const from = (_e = event.from) !== null && _e !== void 0 ? _e : undefined;
324
323
  const to = (_f = event.to) !== null && _f !== void 0 ? _f : undefined;
325
324
  const standard = (_j = (_h = (_g = event.supportedStandards) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.toLowerCase()) !== null && _j !== void 0 ? _j : '';
326
325
  const isErc1155 = this._supportedErc1155Standards.includes(standard);
327
326
  const isErc721 = this._supportedErc721Standards.includes(standard);
328
327
  const isErc20 = this._supportedErc20Standards.includes(standard);
329
- const isNft = (isErc1155 || isErc721) && !!tokenId;
328
+ const isNft = (isErc1155 || isErc721) && !!tokenHash;
330
329
  const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
331
330
  const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
332
- const hashUrl = hash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', hash) : undefined;
331
+ const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
333
332
  if (isNft) {
334
- const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _MoralisBDSEthereum_nftDataService, "f").getNft({ contractHash: hash, tokenId }));
335
- const nftUrl = hash ? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{hash}', hash).replace('{tokenId}', tokenId) : undefined;
333
+ const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _MoralisBDSEthereum_nftDataService, "f").getNft({ collectionHash: contractHash, tokenHash }));
334
+ const nftUrl = contractHash
335
+ ? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{collectionHash}', contractHash).replace('{tokenHash}', tokenHash)
336
+ : undefined;
336
337
  nftEvent = {
337
338
  eventType: 'nft',
338
339
  amount: undefined,
@@ -341,30 +342,30 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
341
342
  fromUrl,
342
343
  to,
343
344
  toUrl,
344
- hash,
345
- hashUrl,
346
- tokenId,
345
+ collectionHash: contractHash,
346
+ collectionHashUrl: contractHashUrl,
347
+ tokenHash,
347
348
  tokenType: isErc1155 ? 'erc-1155' : 'erc-721',
348
349
  nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
349
350
  nftUrl,
350
351
  name: nft === null || nft === void 0 ? void 0 : nft.name,
351
- collectionName: nft === null || nft === void 0 ? void 0 : nft.collectionName,
352
+ collectionName: (_k = nft === null || nft === void 0 ? void 0 : nft.collection) === null || _k === void 0 ? void 0 : _k.name,
352
353
  };
353
354
  }
354
355
  else {
355
- const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(hash));
356
+ const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
356
357
  assetEvent = {
357
358
  eventType: 'token',
358
359
  amount: event.amount
359
- ? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_k = token === null || token === void 0 ? void 0 : token.decimals) !== null && _k !== void 0 ? _k : event.tokenDecimals })
360
+ ? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_l = token === null || token === void 0 ? void 0 : token.decimals) !== null && _l !== void 0 ? _l : event.tokenDecimals })
360
361
  : undefined,
361
362
  methodName,
362
363
  from,
363
364
  fromUrl,
364
365
  to,
365
366
  toUrl,
366
- hash,
367
- hashUrl,
367
+ contractHash,
368
+ contractHashUrl,
368
369
  token: token !== null && token !== void 0 ? token : undefined,
369
370
  tokenType: isErc20 ? 'erc-20' : 'generic',
370
371
  };
@@ -1,10 +1,11 @@
1
- import { BalanceResponse, BlockchainDataService, ContractResponse, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NetworkId, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
1
+ import { BalanceResponse, BlockchainDataService, ContractResponse, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NetworkId, RpcResponse, Token, TokenService, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
2
  import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
3
3
  export declare class RpcBDSEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> implements BlockchainDataService {
4
- _network: Network<BSNetworkId>;
4
+ readonly _network: Network<BSNetworkId>;
5
+ readonly _tokenService: TokenService;
5
6
  _tokenCache: Map<string, Token>;
6
7
  maxTimeToConfirmTransactionInMs: number;
7
- constructor(network: Network<BSNetworkId>);
8
+ constructor(network: Network<BSNetworkId>, tokenService: TokenService);
8
9
  getTransaction(hash: string): Promise<TransactionResponse>;
9
10
  getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
10
11
  getFullTransactionsByAddress(_params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
@@ -13,12 +13,12 @@ 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");
17
16
  class RpcBDSEthereum {
18
- constructor(network) {
17
+ constructor(network, tokenService) {
19
18
  this._tokenCache = new Map();
20
19
  this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5;
21
20
  this._network = network;
21
+ this._tokenService = tokenService;
22
22
  }
23
23
  getTransaction(hash) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
@@ -72,7 +72,7 @@ class RpcBDSEthereum {
72
72
  getTokenInfo(hash) {
73
73
  return __awaiter(this, void 0, void 0, function* () {
74
74
  const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
75
- if (BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(nativeAsset)({ hash }))
75
+ if (this._tokenService.predicateByHash(nativeAsset)({ hash }))
76
76
  return nativeAsset;
77
77
  if (this._tokenCache.has(hash)) {
78
78
  return this._tokenCache.get(hash);
@@ -81,7 +81,7 @@ class RpcBDSEthereum {
81
81
  const contract = new ethers_1.ethers.Contract(hash, ERC20_1.ERC20_ABI, provider);
82
82
  const decimals = yield contract.decimals();
83
83
  const symbol = yield contract.symbol();
84
- const token = BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken({
84
+ const token = this._tokenService.normalizeToken({
85
85
  decimals,
86
86
  symbol,
87
87
  hash,
@@ -1,8 +1,8 @@
1
- import { BlockchainDataService, CryptoCompareEDS, ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
1
+ import { BlockchainDataService, CryptoCompareEDS, ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse, TokenService } from '@cityofzion/blockchain-service';
2
2
  import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
3
3
  export declare class MoralisEDSEthereum extends CryptoCompareEDS implements ExchangeDataService {
4
4
  #private;
5
- constructor(network: Network<BSEthereumNetworkId>, blockchainDataService: BlockchainDataService);
5
+ constructor(network: Network<BSEthereumNetworkId>, blockchainDataService: BlockchainDataService, tokenService: TokenService);
6
6
  getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
7
7
  getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
8
8
  }
@@ -19,16 +19,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
19
19
  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");
20
20
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
21
  };
22
- var _MoralisEDSEthereum_instances, _MoralisEDSEthereum_network, _MoralisEDSEthereum_blockchainDataService, _MoralisEDSEthereum_numberOfBlockByHour, _MoralisEDSEthereum_numberOfBlockByDay, _MoralisEDSEthereum_maxTokenPricesPerCall, _MoralisEDSEthereum_getWrappedNativeToken;
22
+ var _MoralisEDSEthereum_instances, _MoralisEDSEthereum_network, _MoralisEDSEthereum_blockchainDataService, _MoralisEDSEthereum_numberOfBlockByHour, _MoralisEDSEthereum_numberOfBlockByDay, _MoralisEDSEthereum_maxTokenPricesPerCall, _MoralisEDSEthereum_tokenService, _MoralisEDSEthereum_getWrappedNativeToken;
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.MoralisEDSEthereum = void 0;
25
25
  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");
30
29
  class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
31
- constructor(network, blockchainDataService) {
30
+ constructor(network, blockchainDataService, tokenService) {
32
31
  super();
33
32
  _MoralisEDSEthereum_instances.add(this);
34
33
  _MoralisEDSEthereum_network.set(this, void 0);
@@ -36,8 +35,10 @@ class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
36
35
  _MoralisEDSEthereum_numberOfBlockByHour.set(this, (15 / 60) * 60);
37
36
  _MoralisEDSEthereum_numberOfBlockByDay.set(this, __classPrivateFieldGet(this, _MoralisEDSEthereum_numberOfBlockByHour, "f") * 24);
38
37
  _MoralisEDSEthereum_maxTokenPricesPerCall.set(this, 24);
38
+ _MoralisEDSEthereum_tokenService.set(this, void 0);
39
39
  __classPrivateFieldSet(this, _MoralisEDSEthereum_network, network, "f");
40
40
  __classPrivateFieldSet(this, _MoralisEDSEthereum_blockchainDataService, blockchainDataService, "f");
41
+ __classPrivateFieldSet(this, _MoralisEDSEthereum_tokenService, tokenService, "f");
41
42
  }
42
43
  getTokenPrices(params) {
43
44
  return __awaiter(this, void 0, void 0, function* () {
@@ -78,7 +79,7 @@ class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
78
79
  });
79
80
  data.forEach(item => {
80
81
  let token;
81
- if (wrappedNativeToken && BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(wrappedNativeToken)(item.tokenAddress)) {
82
+ if (wrappedNativeToken && __classPrivateFieldGet(this, _MoralisEDSEthereum_tokenService, "f").predicateByHash(wrappedNativeToken)(item.tokenAddress)) {
82
83
  token = nativeToken;
83
84
  }
84
85
  else {
@@ -106,7 +107,7 @@ class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
106
107
  throw new Error('Exchange is not supported on this network');
107
108
  const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _MoralisEDSEthereum_network, "f"));
108
109
  let token;
109
- if (BSEthereumTokenHelper_1.BSEthereumTokenHelper.predicateByHash(nativeToken)(params.token)) {
110
+ if (__classPrivateFieldGet(this, _MoralisEDSEthereum_tokenService, "f").predicateByHash(nativeToken)(params.token)) {
110
111
  token = yield __classPrivateFieldGet(this, _MoralisEDSEthereum_instances, "m", _MoralisEDSEthereum_getWrappedNativeToken).call(this);
111
112
  }
112
113
  else {
@@ -138,13 +139,13 @@ class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
138
139
  }
139
140
  }
140
141
  exports.MoralisEDSEthereum = MoralisEDSEthereum;
141
- _MoralisEDSEthereum_network = new WeakMap(), _MoralisEDSEthereum_blockchainDataService = new WeakMap(), _MoralisEDSEthereum_numberOfBlockByHour = new WeakMap(), _MoralisEDSEthereum_numberOfBlockByDay = new WeakMap(), _MoralisEDSEthereum_maxTokenPricesPerCall = new WeakMap(), _MoralisEDSEthereum_instances = new WeakSet(), _MoralisEDSEthereum_getWrappedNativeToken = function _MoralisEDSEthereum_getWrappedNativeToken() {
142
+ _MoralisEDSEthereum_network = new WeakMap(), _MoralisEDSEthereum_blockchainDataService = new WeakMap(), _MoralisEDSEthereum_numberOfBlockByHour = new WeakMap(), _MoralisEDSEthereum_numberOfBlockByDay = new WeakMap(), _MoralisEDSEthereum_maxTokenPricesPerCall = new WeakMap(), _MoralisEDSEthereum_tokenService = new WeakMap(), _MoralisEDSEthereum_instances = new WeakSet(), _MoralisEDSEthereum_getWrappedNativeToken = function _MoralisEDSEthereum_getWrappedNativeToken() {
142
143
  return __awaiter(this, void 0, void 0, function* () {
143
144
  const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _MoralisEDSEthereum_network, "f"));
144
145
  const wrappedSymbol = `W${nativeToken.symbol}`;
145
146
  const localWrappedHash = BSEthereumConstants_1.BSEthereumConstants.NATIVE_WRAPPED_HASH_BY_NETWORK_ID[__classPrivateFieldGet(this, _MoralisEDSEthereum_network, "f").id];
146
147
  if (!localWrappedHash)
147
148
  throw new Error('Wrapper token not found');
148
- return BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeToken(Object.assign(Object.assign({}, nativeToken), { symbol: wrappedSymbol, hash: localWrappedHash }));
149
+ return __classPrivateFieldGet(this, _MoralisEDSEthereum_tokenService, "f").normalizeToken(Object.assign(Object.assign({}, nativeToken), { symbol: wrappedSymbol, hash: localWrappedHash }));
149
150
  });
150
151
  };
@@ -1,8 +1,8 @@
1
- import { BuildNftUrlParams, ExplorerService, Network, NetworkId } from '@cityofzion/blockchain-service';
1
+ import { BuildNftUrlParams, ExplorerService, Network, NetworkId, TokenService } from '@cityofzion/blockchain-service';
2
2
  import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
3
3
  export declare class BlockscoutESEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> implements ExplorerService {
4
4
  #private;
5
- constructor(network: Network<BSEthereumNetworkId>, baseUrlByNetworkId?: Partial<Record<BSNetworkId, string>>);
5
+ constructor(network: Network<BSEthereumNetworkId>, tokenService: TokenService, baseUrlByNetworkId?: Partial<Record<BSNetworkId, string>>);
6
6
  buildTransactionUrl(hash: string): string;
7
7
  buildContractUrl(contractHash: string): string;
8
8
  buildNftUrl(params: BuildNftUrlParams): string;
@@ -10,11 +10,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  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");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _BlockscoutESEthereum_instances, _BlockscoutESEthereum_network, _BlockscoutESEthereum_baseUrlByNetworkId, _BlockscoutESEthereum_getBaseUrl;
13
+ var _BlockscoutESEthereum_instances, _BlockscoutESEthereum_network, _BlockscoutESEthereum_baseUrlByNetworkId, _BlockscoutESEthereum_tokenService, _BlockscoutESEthereum_getBaseUrl;
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");
18
17
  const DEFAULT_BASE_URL_BY_NETWORK_ID = {
19
18
  [BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID]: 'https://eth.blockscout.com',
20
19
  '10': 'https://optimism.blockscout.com',
@@ -27,24 +26,26 @@ const DEFAULT_BASE_URL_BY_NETWORK_ID = {
27
26
  '11155111': 'https://eth-sepolia.blockscout.com',
28
27
  };
29
28
  class BlockscoutESEthereum {
30
- constructor(network, baseUrlByNetworkId) {
29
+ constructor(network, tokenService, baseUrlByNetworkId) {
31
30
  _BlockscoutESEthereum_instances.add(this);
32
31
  _BlockscoutESEthereum_network.set(this, void 0);
33
32
  _BlockscoutESEthereum_baseUrlByNetworkId.set(this, void 0);
33
+ _BlockscoutESEthereum_tokenService.set(this, void 0);
34
34
  __classPrivateFieldSet(this, _BlockscoutESEthereum_network, network, "f");
35
35
  __classPrivateFieldSet(this, _BlockscoutESEthereum_baseUrlByNetworkId, baseUrlByNetworkId !== null && baseUrlByNetworkId !== void 0 ? baseUrlByNetworkId : DEFAULT_BASE_URL_BY_NETWORK_ID, "f");
36
+ __classPrivateFieldSet(this, _BlockscoutESEthereum_tokenService, tokenService, "f");
36
37
  }
37
38
  buildTransactionUrl(hash) {
38
39
  const baseURL = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
39
- return `${baseURL}/tx/${BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeHash(hash)}`;
40
+ return `${baseURL}/tx/${__classPrivateFieldGet(this, _BlockscoutESEthereum_tokenService, "f").normalizeHash(hash)}`;
40
41
  }
41
42
  buildContractUrl(contractHash) {
42
43
  const baseURL = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
43
- return `${baseURL}/address/${BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeHash(contractHash)}`;
44
+ return `${baseURL}/address/${__classPrivateFieldGet(this, _BlockscoutESEthereum_tokenService, "f").normalizeHash(contractHash)}`;
44
45
  }
45
46
  buildNftUrl(params) {
46
47
  const baseURL = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
47
- return `${baseURL}/token/${BSEthereumTokenHelper_1.BSEthereumTokenHelper.normalizeHash(params.contractHash)}/instance/${params.tokenId}`;
48
+ return `${baseURL}/token/${__classPrivateFieldGet(this, _BlockscoutESEthereum_tokenService, "f").normalizeHash(params.collectionHash)}/instance/${params.tokenHash}`;
48
49
  }
49
50
  getAddressTemplateUrl() {
50
51
  try {
@@ -67,7 +68,7 @@ class BlockscoutESEthereum {
67
68
  getNftTemplateUrl() {
68
69
  try {
69
70
  const baseUrl = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
70
- return `${baseUrl}/token/{hash}/instance/{tokenId}`;
71
+ return `${baseUrl}/token/{collectionHash}/instance/{tokenHash}`;
71
72
  }
72
73
  catch (_a) {
73
74
  return undefined;
@@ -84,7 +85,7 @@ class BlockscoutESEthereum {
84
85
  }
85
86
  }
86
87
  exports.BlockscoutESEthereum = BlockscoutESEthereum;
87
- _BlockscoutESEthereum_network = new WeakMap(), _BlockscoutESEthereum_baseUrlByNetworkId = new WeakMap(), _BlockscoutESEthereum_instances = new WeakSet(), _BlockscoutESEthereum_getBaseUrl = function _BlockscoutESEthereum_getBaseUrl(network) {
88
+ _BlockscoutESEthereum_network = new WeakMap(), _BlockscoutESEthereum_baseUrlByNetworkId = new WeakMap(), _BlockscoutESEthereum_tokenService = new WeakMap(), _BlockscoutESEthereum_instances = new WeakSet(), _BlockscoutESEthereum_getBaseUrl = function _BlockscoutESEthereum_getBaseUrl(network) {
88
89
  const baseUrl = __classPrivateFieldGet(this, _BlockscoutESEthereum_baseUrlByNetworkId, "f")[network.id];
89
90
  if (!baseUrl) {
90
91
  throw new Error('Network not supported');
@@ -5,7 +5,7 @@ export declare class GhostMarketNDSEthereum<BSNetworkId extends NetworkId = BSEt
5
5
  #private;
6
6
  constructor(network: Network<BSNetworkId>, ghostMarketChainByNetworkId?: Partial<Record<BSNetworkId, string>>);
7
7
  getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
8
- getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
8
+ getNft({ collectionHash, tokenHash }: GetNftParam): Promise<NftResponse>;
9
9
  private treatGhostMarketImage;
10
10
  private getUrlWithParams;
11
11
  private parse;
@@ -58,11 +58,11 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
58
58
  return { nextCursor: request.data.next, items: nfts.map(this.parse.bind(this)) };
59
59
  });
60
60
  }
61
- getNft({ contractHash, tokenId }) {
61
+ getNft({ collectionHash, tokenHash }) {
62
62
  return __awaiter(this, void 0, void 0, function* () {
63
63
  const url = this.getUrlWithParams({
64
- contract: contractHash,
65
- tokenIds: [tokenId],
64
+ contract: collectionHash,
65
+ tokenIds: [tokenHash],
66
66
  });
67
67
  const request = yield axios_1.default.get(url);
68
68
  return this.parse(request.data.assets[0]);
@@ -89,11 +89,13 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
89
89
  parse(data) {
90
90
  var _a, _b;
91
91
  const nftResponse = {
92
- collectionImage: this.treatGhostMarketImage((_a = data.collection) === null || _a === void 0 ? void 0 : _a.logoUrl),
93
- id: data.tokenId,
94
- contractHash: data.contract.hash,
92
+ hash: data.tokenId,
93
+ collection: {
94
+ hash: data.contract.hash,
95
+ name: (_a = data.collection) === null || _a === void 0 ? void 0 : _a.name,
96
+ image: this.treatGhostMarketImage((_b = data.collection) === null || _b === void 0 ? void 0 : _b.logoUrl),
97
+ },
95
98
  symbol: data.contract.symbol,
96
- collectionName: (_b = data.collection) === null || _b === void 0 ? void 0 : _b.name,
97
99
  image: this.treatGhostMarketImage(data.metadata.mediaUri),
98
100
  isSVG: String(data.metadata.mediaType).includes('svg+xml'),
99
101
  name: data.metadata.name,
@@ -4,5 +4,5 @@ export declare abstract class RpcNDSEthereum implements NftDataService {
4
4
  protected constructor(network: Network);
5
5
  abstract getNftsByAddress(params: GetNftsByAddressParams): Promise<NftsResponse>;
6
6
  abstract getNft(params: GetNftParam): Promise<NftResponse>;
7
- hasToken({ contractHash, address }: HasTokenParam): Promise<boolean>;
7
+ hasToken({ collectionHash, address }: HasTokenParam): Promise<boolean>;
8
8
  }
@@ -29,11 +29,11 @@ class RpcNDSEthereum {
29
29
  _RpcNDSEthereum_network.set(this, void 0);
30
30
  __classPrivateFieldSet(this, _RpcNDSEthereum_network, network, "f");
31
31
  }
32
- hasToken({ contractHash, address }) {
32
+ hasToken({ collectionHash, address }) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
34
  try {
35
35
  const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcNDSEthereum_network, "f").url);
36
- const contract = new ethers_1.ethers.Contract(contractHash, ERC20_1.ERC20_ABI, provider);
36
+ const contract = new ethers_1.ethers.Contract(collectionHash, ERC20_1.ERC20_ABI, provider);
37
37
  const response = yield contract.balanceOf(address);
38
38
  if (!response)
39
39
  throw new Error();
@@ -41,7 +41,7 @@ class RpcNDSEthereum {
41
41
  return parsedResponse.gt(0);
42
42
  }
43
43
  catch (_a) {
44
- throw new Error(`Token not found: ${contractHash}`);
44
+ throw new Error(`Token not found: ${collectionHash}`);
45
45
  }
46
46
  });
47
47
  }
@@ -0,0 +1,4 @@
1
+ import { TokenService } from '@cityofzion/blockchain-service';
2
+ export declare class TokenServiceEthereum extends TokenService {
3
+ normalizeHash(hash: string): string;
4
+ }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BSEthereumTokenHelper = void 0;
3
+ exports.TokenServiceEthereum = void 0;
4
4
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
5
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);
6
+ class TokenServiceEthereum extends blockchain_service_1.TokenService {
7
+ normalizeHash(hash) {
8
+ let fixedHash = hash.startsWith('0x') ? hash : `0x${hash}`;
9
9
  try {
10
10
  fixedHash = ethers_1.ethers.utils.getAddress(fixedHash); // Normalize to checksum address
11
11
  }
@@ -15,4 +15,4 @@ class BSEthereumTokenHelper extends blockchain_service_1.BSTokenHelper {
15
15
  return fixedHash;
16
16
  }
17
17
  }
18
- exports.BSEthereumTokenHelper = BSEthereumTokenHelper;
18
+ exports.TokenServiceEthereum = TokenServiceEthereum;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-ethereum",
3
- "version": "2.13.0",
3
+ "version": "2.13.1",
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.20.0"
25
+ "@cityofzion/blockchain-service": "1.21.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@ledgerhq/hw-transport-node-hid": "~6.28.5",
@@ -1,4 +0,0 @@
1
- import { BSTokenHelper } from '@cityofzion/blockchain-service';
2
- export declare class BSEthereumTokenHelper extends BSTokenHelper {
3
- static normalizeHash(hash: string): string;
4
- }