@cityofzion/bs-ethereum 2.1.2 → 2.2.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.
@@ -48,6 +48,8 @@ const EthersLedgerServiceEthereum_1 = require("./EthersLedgerServiceEthereum");
48
48
  const BSEthereumHelper_1 = require("./BSEthereumHelper");
49
49
  const MoralisBDSEthereum_1 = require("./MoralisBDSEthereum");
50
50
  const MoralisEDSEthereum_1 = require("./MoralisEDSEthereum");
51
+ const BlockscoutNeoXBDSEthereum_1 = require("./BlockscoutNeoXBDSEthereum");
52
+ const BlockscoutNeoXEDSEthereum_1 = require("./BlockscoutNeoXEDSEthereum");
51
53
  class BSEthereum {
52
54
  constructor(blockchainName, network, getLedgerTransport) {
53
55
  _BSEthereum_instances.add(this);
@@ -60,8 +62,14 @@ class BSEthereum {
60
62
  setNetwork(network) {
61
63
  __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_setTokens).call(this, network);
62
64
  this.network = network;
63
- this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(network);
64
- this.exchangeDataService = new MoralisEDSEthereum_1.MoralisEDSEthereum(network, this.blockchainDataService);
65
+ if (BlockscoutNeoXBDSEthereum_1.BlockscoutNeoXBDSEthereum.isSupported(network)) {
66
+ this.exchangeDataService = new BlockscoutNeoXEDSEthereum_1.BlockscoutNeoXEDSEthereum(network);
67
+ this.blockchainDataService = new BlockscoutNeoXBDSEthereum_1.BlockscoutNeoXBDSEthereum(network);
68
+ }
69
+ else {
70
+ this.exchangeDataService = new MoralisEDSEthereum_1.MoralisEDSEthereum(network, this.blockchainDataService);
71
+ this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(network);
72
+ }
65
73
  this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network);
66
74
  }
67
75
  validateAddress(address) {
@@ -1,12 +1,14 @@
1
1
  import { Network, NetworkId } from '@cityofzion/blockchain-service';
2
- export type BSEthereumNetworkId = NetworkId<'1' | '10' | '25' | '56' | '137' | '250' | '1101' | '8453' | '80002' | '42161' | '42220' | '43114' | '59144' | '11155111' | '12227331'>;
2
+ export type BSEthereumNetworkId = NetworkId<'1' | '10' | '25' | '56' | '137' | '250' | '1101' | '8453' | '80002' | '42161' | '42220' | '43114' | '59144' | '11155111' | '47763' | '12227332'>;
3
3
  export declare class BSEthereumHelper {
4
4
  #private;
5
5
  static DERIVATION_PATH: string;
6
6
  static DEFAULT_PATH: string;
7
7
  static NEOX_TESTNET_NETWORK_ID: BSEthereumNetworkId;
8
+ static NEOX_MAINNET_NETWORK_ID: BSEthereumNetworkId;
8
9
  static NEOX_NETWORK_IDS: BSEthereumNetworkId[];
9
10
  static NEOX_TESTNET_NETWORK: Network<BSEthereumNetworkId>;
11
+ static NEOX_MAINNET_NETWORK: Network<BSEthereumNetworkId>;
10
12
  static NEOX_NETWORKS: Network<BSEthereumNetworkId>[];
11
13
  static MAINNET_NETWORK_IDS: BSEthereumNetworkId[];
12
14
  static TESTNET_NETWORK_IDS: BSEthereumNetworkId[];
@@ -50,7 +50,8 @@ _BSEthereumHelper_NATIVE_SYMBOL_BY_NETWORK_ID = { value: {
50
50
  '43114': 'AVAX',
51
51
  '59144': 'ETH',
52
52
  '11155111': 'ETH',
53
- '12227331': 'GAS',
53
+ '47763': 'GAS',
54
+ '12227332': 'GAS',
54
55
  } };
55
56
  _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID = { value: {
56
57
  '1': [
@@ -141,18 +142,25 @@ _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID = { value: {
141
142
  'https://1rpc.io/sepolia',
142
143
  'https://eth-sepolia.api.onfinality.io/public',
143
144
  ],
144
- '12227331': ['https://neoxseed1.ngd.network'],
145
+ '47763': ['https://mainnet-1.rpc.banelabs.org'],
146
+ '12227332': ['https://neoxt4seed1.ngd.network'],
145
147
  } };
146
148
  BSEthereumHelper.DERIVATION_PATH = "m/44'/60'/0'/0/?";
147
149
  BSEthereumHelper.DEFAULT_PATH = "44'/60'/0'/0/0";
148
- BSEthereumHelper.NEOX_TESTNET_NETWORK_ID = '12227331';
149
- BSEthereumHelper.NEOX_NETWORK_IDS = [_a.NEOX_TESTNET_NETWORK_ID];
150
+ BSEthereumHelper.NEOX_TESTNET_NETWORK_ID = '12227332';
151
+ BSEthereumHelper.NEOX_MAINNET_NETWORK_ID = '47763';
152
+ BSEthereumHelper.NEOX_NETWORK_IDS = [_a.NEOX_TESTNET_NETWORK_ID, _a.NEOX_MAINNET_NETWORK_ID];
150
153
  BSEthereumHelper.NEOX_TESTNET_NETWORK = {
151
154
  id: _a.NEOX_TESTNET_NETWORK_ID,
152
155
  name: 'NeoX Testnet',
153
156
  url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)[_a.NEOX_TESTNET_NETWORK_ID][0],
154
157
  };
155
- BSEthereumHelper.NEOX_NETWORKS = [_a.NEOX_TESTNET_NETWORK];
158
+ BSEthereumHelper.NEOX_MAINNET_NETWORK = {
159
+ id: _a.NEOX_MAINNET_NETWORK_ID,
160
+ name: 'NeoX Mainnet',
161
+ url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)[_a.NEOX_MAINNET_NETWORK_ID][0],
162
+ };
163
+ BSEthereumHelper.NEOX_NETWORKS = [_a.NEOX_TESTNET_NETWORK, _a.NEOX_MAINNET_NETWORK];
156
164
  BSEthereumHelper.MAINNET_NETWORK_IDS = [
157
165
  '1',
158
166
  '10',
@@ -165,14 +173,9 @@ BSEthereumHelper.MAINNET_NETWORK_IDS = [
165
173
  '42220',
166
174
  '43114',
167
175
  '59144',
176
+ _a.NEOX_MAINNET_NETWORK_ID,
168
177
  ];
169
- BSEthereumHelper.TESTNET_NETWORK_IDS = [
170
- '1101',
171
- '80002',
172
- '11155111',
173
- '12227331',
174
- _a.NEOX_TESTNET_NETWORK_ID,
175
- ];
178
+ BSEthereumHelper.TESTNET_NETWORK_IDS = ['1101', '80002', '11155111', _a.NEOX_TESTNET_NETWORK_ID];
176
179
  BSEthereumHelper.ALL_NETWORK_IDS = [..._a.MAINNET_NETWORK_IDS, ..._a.TESTNET_NETWORK_IDS];
177
180
  BSEthereumHelper.MAINNET_NETWORKS = [
178
181
  {
@@ -230,6 +233,7 @@ BSEthereumHelper.MAINNET_NETWORKS = [
230
233
  name: 'Linea Mainnet',
231
234
  url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['59144'][0],
232
235
  },
236
+ _a.NEOX_MAINNET_NETWORK,
233
237
  ];
234
238
  BSEthereumHelper.TESTNET_NETWORKS = [
235
239
  {
@@ -0,0 +1,17 @@
1
+ import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
+ import { RpcBDSEthereum } from './RpcBDSEthereum';
3
+ import { BSEthereumNetworkId } from './BSEthereumHelper';
4
+ export declare class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum {
5
+ #private;
6
+ static BASE_URL_BY_CHAIN_ID: Partial<Record<BSEthereumNetworkId, string>>;
7
+ static isSupported(network: Network<BSEthereumNetworkId>): boolean;
8
+ static getClient(network: Network<BSEthereumNetworkId>): import("axios").AxiosInstance;
9
+ constructor(network: Network<BSEthereumNetworkId>);
10
+ maxTimeToConfirmTransactionInMs: number;
11
+ getTransaction(txid: string): Promise<TransactionResponse>;
12
+ getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
13
+ getContract(contractHash: string): Promise<ContractResponse>;
14
+ getTokenInfo(tokenHash: string): Promise<Token>;
15
+ getBalance(address: string): Promise<BalanceResponse[]>;
16
+ getBlockHeight(): Promise<number>;
17
+ }
@@ -0,0 +1,255 @@
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
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ var _BlockscoutNeoXBDSEthereum_instances, _BlockscoutNeoXBDSEthereum_parseTransfers;
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.BlockscoutNeoXBDSEthereum = void 0;
22
+ const axios_1 = __importDefault(require("axios"));
23
+ const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
24
+ const BSEthereumHelper_1 = require("./BSEthereumHelper");
25
+ const ethers_1 = require("ethers");
26
+ class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
27
+ static isSupported(network) {
28
+ return !!BlockscoutNeoXBDSEthereum.BASE_URL_BY_CHAIN_ID[network.id];
29
+ }
30
+ static getClient(network) {
31
+ const baseURL = BlockscoutNeoXBDSEthereum.BASE_URL_BY_CHAIN_ID[network.id];
32
+ if (!baseURL) {
33
+ throw new Error('Unsupported network');
34
+ }
35
+ return axios_1.default.create({
36
+ baseURL,
37
+ });
38
+ }
39
+ constructor(network) {
40
+ super(network);
41
+ _BlockscoutNeoXBDSEthereum_instances.add(this);
42
+ this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5;
43
+ }
44
+ getTransaction(txid) {
45
+ const _super = Object.create(null, {
46
+ getTransaction: { get: () => super.getTransaction }
47
+ });
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ if (!BlockscoutNeoXBDSEthereum.isSupported(this._network)) {
50
+ return _super.getTransaction.call(this, txid);
51
+ }
52
+ const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
53
+ const { data } = yield client.get(`/transactions/${txid}`);
54
+ const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
55
+ const transfers = __classPrivateFieldGet(this, _BlockscoutNeoXBDSEthereum_instances, "m", _BlockscoutNeoXBDSEthereum_parseTransfers).call(this, data, nativeToken);
56
+ return {
57
+ block: data.block,
58
+ hash: data.hash,
59
+ fee: ethers_1.ethers.utils.formatUnits(data.fee.value, nativeToken.decimals),
60
+ time: new Date(data.timestamp).getTime(),
61
+ notifications: [],
62
+ transfers,
63
+ };
64
+ });
65
+ }
66
+ getTransactionsByAddress(params) {
67
+ const _super = Object.create(null, {
68
+ getTransactionsByAddress: { get: () => super.getTransactionsByAddress }
69
+ });
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ if (!BlockscoutNeoXBDSEthereum.isSupported(this._network)) {
72
+ return _super.getTransactionsByAddress.call(this, params);
73
+ }
74
+ const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
75
+ const { data } = yield client.get(`/addresses/${params.address}/transactions`, {
76
+ params: {
77
+ next_page_params: params.nextPageParams,
78
+ },
79
+ });
80
+ const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
81
+ const transactions = [];
82
+ data.items.forEach(item => {
83
+ const transfers = __classPrivateFieldGet(this, _BlockscoutNeoXBDSEthereum_instances, "m", _BlockscoutNeoXBDSEthereum_parseTransfers).call(this, item, nativeToken);
84
+ transactions.push({
85
+ block: item.block,
86
+ hash: item.hash,
87
+ fee: ethers_1.ethers.utils.formatUnits(item.fee.value, nativeToken.decimals),
88
+ time: new Date(item.timestamp).getTime(),
89
+ notifications: [],
90
+ transfers,
91
+ });
92
+ });
93
+ return {
94
+ transactions,
95
+ nextPageParams: data.next_page_params,
96
+ };
97
+ });
98
+ }
99
+ getContract(contractHash) {
100
+ const _super = Object.create(null, {
101
+ getContract: { get: () => super.getContract }
102
+ });
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ if (!BlockscoutNeoXBDSEthereum.isSupported(this._network)) {
105
+ return _super.getContract.call(this, contractHash);
106
+ }
107
+ try {
108
+ const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
109
+ const { data } = yield client.get(`/smart-contracts/${contractHash}`);
110
+ const methods = [];
111
+ data.abi.forEach(abi => {
112
+ var _a, _b;
113
+ if (abi.type !== 'function')
114
+ return;
115
+ const parameters = (_a = abi.inputs) === null || _a === void 0 ? void 0 : _a.map(param => ({
116
+ name: param.name,
117
+ type: param.type,
118
+ }));
119
+ methods.push({
120
+ name: (_b = abi.name) !== null && _b !== void 0 ? _b : '',
121
+ parameters: parameters !== null && parameters !== void 0 ? parameters : [],
122
+ });
123
+ });
124
+ return {
125
+ hash: contractHash,
126
+ name: data.name,
127
+ methods,
128
+ };
129
+ }
130
+ catch (error) {
131
+ throw new Error('Contract not found or not supported');
132
+ }
133
+ });
134
+ }
135
+ getTokenInfo(tokenHash) {
136
+ const _super = Object.create(null, {
137
+ getTokenInfo: { get: () => super.getTokenInfo }
138
+ });
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ if (!BlockscoutNeoXBDSEthereum.isSupported(this._network)) {
141
+ return _super.getTokenInfo.call(this, tokenHash);
142
+ }
143
+ const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
144
+ if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(nativeAsset.hash) === BSEthereumHelper_1.BSEthereumHelper.normalizeHash(tokenHash)) {
145
+ return nativeAsset;
146
+ }
147
+ if (this._tokenCache.has(tokenHash)) {
148
+ return this._tokenCache.get(tokenHash);
149
+ }
150
+ const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
151
+ const { data } = yield client.get(`/tokens/${tokenHash}`);
152
+ return {
153
+ decimals: parseInt(data.decimals),
154
+ hash: tokenHash,
155
+ name: data.name,
156
+ symbol: data.symbol,
157
+ };
158
+ });
159
+ }
160
+ getBalance(address) {
161
+ const _super = Object.create(null, {
162
+ getBalance: { get: () => super.getBalance }
163
+ });
164
+ return __awaiter(this, void 0, void 0, function* () {
165
+ if (!BlockscoutNeoXBDSEthereum.isSupported(this._network)) {
166
+ return _super.getBalance.call(this, address);
167
+ }
168
+ const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
169
+ const { data: nativeBalance } = yield client.get(`/addresses/${address}`);
170
+ const balances = [
171
+ {
172
+ amount: ethers_1.ethers.utils.formatUnits(nativeBalance.coin_balance, 18),
173
+ token: BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network),
174
+ },
175
+ ];
176
+ const { data: erc20Balances } = yield client.get(`/addresses/${address}/token-balances`);
177
+ erc20Balances.forEach(balance => {
178
+ const token = {
179
+ decimals: parseInt(balance.token.decimals),
180
+ hash: balance.token.address,
181
+ name: balance.token.symbol,
182
+ symbol: balance.token.symbol,
183
+ };
184
+ balances.push({
185
+ amount: ethers_1.ethers.utils.formatUnits(balance.value, token.decimals),
186
+ token,
187
+ });
188
+ });
189
+ return balances;
190
+ });
191
+ }
192
+ getBlockHeight() {
193
+ const _super = Object.create(null, {
194
+ getBlockHeight: { get: () => super.getBlockHeight }
195
+ });
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ if (!BlockscoutNeoXBDSEthereum.isSupported(this._network)) {
198
+ return _super.getBlockHeight.call(this);
199
+ }
200
+ const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
201
+ const { data } = yield client.get('/blocks');
202
+ return data.items[0].height;
203
+ });
204
+ }
205
+ }
206
+ exports.BlockscoutNeoXBDSEthereum = BlockscoutNeoXBDSEthereum;
207
+ _BlockscoutNeoXBDSEthereum_instances = new WeakSet(), _BlockscoutNeoXBDSEthereum_parseTransfers = function _BlockscoutNeoXBDSEthereum_parseTransfers(item, nativeToken) {
208
+ const transfers = [];
209
+ const hasNativeTokenBeingTransferred = item.value !== '0';
210
+ if (hasNativeTokenBeingTransferred) {
211
+ transfers.push({
212
+ amount: ethers_1.ethers.utils.formatUnits(item.value, nativeToken.decimals),
213
+ from: item.from.hash,
214
+ to: item.to.hash,
215
+ type: 'token',
216
+ contractHash: nativeToken.hash,
217
+ token: nativeToken,
218
+ });
219
+ }
220
+ const hasTokenTransfers = item.token_transfers && item.token_transfers.length > 0;
221
+ if (hasTokenTransfers) {
222
+ for (const tokenTransfer of item.token_transfers) {
223
+ if (tokenTransfer.token.type === 'ERC-20') {
224
+ transfers.push({
225
+ amount: ethers_1.ethers.utils.formatUnits(tokenTransfer.total.value, tokenTransfer.total.decimals),
226
+ from: tokenTransfer.from.hash,
227
+ to: tokenTransfer.to.hash,
228
+ type: 'token',
229
+ contractHash: tokenTransfer.token.address,
230
+ token: {
231
+ symbol: tokenTransfer.token.symbol,
232
+ name: tokenTransfer.token.name,
233
+ hash: tokenTransfer.token.address,
234
+ decimals: tokenTransfer.total.decimals,
235
+ },
236
+ });
237
+ continue;
238
+ }
239
+ if (tokenTransfer.token.type === 'ERC-721') {
240
+ transfers.push({
241
+ tokenId: tokenTransfer.total.token_id,
242
+ from: tokenTransfer.from.hash,
243
+ to: tokenTransfer.to.hash,
244
+ type: 'nft',
245
+ contractHash: tokenTransfer.token.address,
246
+ });
247
+ }
248
+ }
249
+ }
250
+ return transfers;
251
+ };
252
+ BlockscoutNeoXBDSEthereum.BASE_URL_BY_CHAIN_ID = {
253
+ '12227332': 'https://dora-stage.coz.io/api/neox/testnet',
254
+ '47763': 'https://dora.coz.io/api/neox/mainnet',
255
+ };
@@ -0,0 +1,7 @@
1
+ import { CryptoCompareEDS, ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
2
+ export declare class BlockscoutNeoXEDSEthereum extends CryptoCompareEDS implements ExchangeDataService {
3
+ #private;
4
+ constructor(network: Network);
5
+ getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
6
+ getTokenPriceHistory(_params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
7
+ }
@@ -0,0 +1,76 @@
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
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ 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");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
+ };
22
+ var _BlockscoutNeoXEDSEthereum_network;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.BlockscoutNeoXEDSEthereum = void 0;
25
+ const blockchain_service_1 = require("@cityofzion/blockchain-service");
26
+ const BSEthereumHelper_1 = require("./BSEthereumHelper");
27
+ const BlockscoutNeoXBDSEthereum_1 = require("./BlockscoutNeoXBDSEthereum");
28
+ class BlockscoutNeoXEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
29
+ constructor(network) {
30
+ super();
31
+ _BlockscoutNeoXEDSEthereum_network.set(this, void 0);
32
+ __classPrivateFieldSet(this, _BlockscoutNeoXEDSEthereum_network, network, "f");
33
+ }
34
+ getTokenPrices(params) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ if (!BSEthereumHelper_1.BSEthereumHelper.isMainnet(__classPrivateFieldGet(this, _BlockscoutNeoXEDSEthereum_network, "f")))
37
+ throw new Error('Exchange is only available on mainnet');
38
+ if (!BlockscoutNeoXBDSEthereum_1.BlockscoutNeoXBDSEthereum.isSupported(__classPrivateFieldGet(this, _BlockscoutNeoXEDSEthereum_network, "f"))) {
39
+ throw new Error('Exchange is not supported on this network');
40
+ }
41
+ const client = BlockscoutNeoXBDSEthereum_1.BlockscoutNeoXBDSEthereum.getClient(__classPrivateFieldGet(this, _BlockscoutNeoXEDSEthereum_network, "f"));
42
+ const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _BlockscoutNeoXEDSEthereum_network, "f"));
43
+ const prices = [];
44
+ const promises = params.tokens.map((token) => __awaiter(this, void 0, void 0, function* () {
45
+ try {
46
+ if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(token.hash) !== BSEthereumHelper_1.BSEthereumHelper.normalizeHash(nativeToken.hash)) {
47
+ const { data } = yield client.get(`/tokens/${token.hash}`);
48
+ prices.push({
49
+ token,
50
+ usdPrice: Number(data.exchange_rate),
51
+ });
52
+ return;
53
+ }
54
+ const { data } = yield client.get(`/stats`);
55
+ prices.push({
56
+ token,
57
+ usdPrice: Number(data.coin_price),
58
+ });
59
+ }
60
+ catch (_a) {
61
+ prices.push({
62
+ token,
63
+ usdPrice: 0,
64
+ });
65
+ }
66
+ }));
67
+ yield Promise.allSettled(promises);
68
+ return prices;
69
+ });
70
+ }
71
+ getTokenPriceHistory(_params) {
72
+ throw new Error('Blockscout does not support this feature');
73
+ }
74
+ }
75
+ exports.BlockscoutNeoXEDSEthereum = BlockscoutNeoXEDSEthereum;
76
+ _BlockscoutNeoXEDSEthereum_network = new WeakMap();
@@ -178,7 +178,7 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
178
178
  const { data } = yield client.get(`/wallets/${params.address}/history`, {
179
179
  params: {
180
180
  limit: 15,
181
- cursor: params.cursor,
181
+ cursor: params.nextPageParams,
182
182
  },
183
183
  });
184
184
  const transactions = [];
@@ -232,7 +232,7 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
232
232
  }));
233
233
  yield Promise.allSettled(promises);
234
234
  return {
235
- nextCursor: data.cursor,
235
+ nextPageParams: data.cursor,
236
236
  transactions,
237
237
  };
238
238
  });
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from './BSEthereum';
2
- export * from './GhostMarketNDSEthereum';
3
- export * from './RpcNDSEthereum';
4
2
  export * from './BSEthereumHelper';
3
+ export * from './EthersLedgerServiceEthereum';
4
+ export * from './GhostMarketNDSEthereum';
5
5
  export * from './MoralisBDSEthereum';
6
- export * from './RpcBDSEthereum';
7
6
  export * from './MoralisEDSEthereum';
8
- export * from './EthersLedgerServiceEthereum';
7
+ export * from './RpcBDSEthereum';
8
+ export * from './RpcNDSEthereum';
package/dist/index.js CHANGED
@@ -15,10 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BSEthereum"), exports);
18
- __exportStar(require("./GhostMarketNDSEthereum"), exports);
19
- __exportStar(require("./RpcNDSEthereum"), exports);
20
18
  __exportStar(require("./BSEthereumHelper"), exports);
19
+ __exportStar(require("./EthersLedgerServiceEthereum"), exports);
20
+ __exportStar(require("./GhostMarketNDSEthereum"), exports);
21
21
  __exportStar(require("./MoralisBDSEthereum"), exports);
22
- __exportStar(require("./RpcBDSEthereum"), exports);
23
22
  __exportStar(require("./MoralisEDSEthereum"), exports);
24
- __exportStar(require("./EthersLedgerServiceEthereum"), exports);
23
+ __exportStar(require("./RpcBDSEthereum"), exports);
24
+ __exportStar(require("./RpcNDSEthereum"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-ethereum",
3
- "version": "2.1.2",
3
+ "version": "2.2.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.1.0"
23
+ "@cityofzion/blockchain-service": "1.2.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@ledgerhq/hw-transport-node-hid": "~6.28.5",