@cityofzion/bs-ethereum 2.13.3 → 2.13.5
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.
- package/dist/BSEthereum.d.ts +28 -23
- package/dist/BSEthereum.js +60 -24
- package/dist/constants/BSEthereumConstants.d.ts +9 -19
- package/dist/constants/BSEthereumConstants.js +100 -101
- package/dist/helpers/BSEthereumHelper.d.ts +4 -7
- package/dist/helpers/BSEthereumHelper.js +3 -9
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/services/blockchain-data/MoralisBDSEthereum.d.ts +20 -15
- package/dist/services/blockchain-data/MoralisBDSEthereum.js +105 -146
- package/dist/services/blockchain-data/RpcBDSEthereum.d.ts +14 -15
- package/dist/services/blockchain-data/RpcBDSEthereum.js +35 -54
- package/dist/services/exchange-data/MoralisEDSEthereum.d.ts +9 -6
- package/dist/services/exchange-data/MoralisEDSEthereum.js +47 -41
- package/dist/services/explorer/BlockscoutESEthereum.d.ts +8 -6
- package/dist/services/explorer/BlockscoutESEthereum.js +29 -48
- package/dist/services/ledger/EthersLedgerServiceEthereum.d.ts +9 -8
- package/dist/services/ledger/EthersLedgerServiceEthereum.js +33 -19
- package/dist/services/nft-data/GhostMarketNDSEthereum.d.ts +8 -11
- package/dist/services/nft-data/GhostMarketNDSEthereum.js +32 -92
- package/dist/types.d.ts +83 -0
- package/dist/types.js +2 -0
- package/package.json +20 -22
- package/dist/services/blockchain-data/DoraBDSEthereum.d.ts +0 -12
- package/dist/services/blockchain-data/DoraBDSEthereum.js +0 -40
- package/dist/services/nft-data/RpcNDSEthereum.d.ts +0 -8
- package/dist/services/nft-data/RpcNDSEthereum.js +0 -50
|
@@ -8,17 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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
|
+
};
|
|
11
16
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
17
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
18
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
19
|
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
20
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
21
|
};
|
|
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
22
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
23
23
|
var t = {};
|
|
24
24
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -33,69 +33,60 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
33
33
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
34
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
35
|
};
|
|
36
|
-
var
|
|
36
|
+
var _MoralisBDSEthereum_instances, _a, _MoralisBDSEthereum_apiInstance, _MoralisBDSEthereum_api_get;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.MoralisBDSEthereum = void 0;
|
|
39
39
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
40
40
|
const axios_1 = __importDefault(require("axios"));
|
|
41
41
|
const ethers_1 = require("ethers");
|
|
42
|
-
const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
|
|
43
42
|
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
44
43
|
const ERC20_1 = require("../../assets/abis/ERC20");
|
|
45
44
|
const dora_ts_1 = require("@cityofzion/dora-ts");
|
|
46
|
-
const
|
|
47
|
-
class MoralisBDSEthereum extends
|
|
45
|
+
const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
46
|
+
class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
48
47
|
static getClient(network) {
|
|
49
48
|
return axios_1.default.create({
|
|
50
|
-
baseURL:
|
|
49
|
+
baseURL: _a.BASE_URL,
|
|
51
50
|
params: {
|
|
52
51
|
chain: `0x${Number(network.id).toString(16)}`,
|
|
53
52
|
},
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
55
|
static isSupported(network) {
|
|
57
|
-
return
|
|
56
|
+
return _a.MORALIS_SUPPORTED_NETWORKS_IDS.includes(network.id);
|
|
58
57
|
}
|
|
59
|
-
constructor(
|
|
60
|
-
super(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID,
|
|
64
|
-
BSEthereumConstants_1.BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID,
|
|
65
|
-
], tokenService);
|
|
66
|
-
_MoralisBDSEthereum_nftDataService.set(this, void 0);
|
|
67
|
-
_MoralisBDSEthereum_explorerService.set(this, void 0);
|
|
68
|
-
__classPrivateFieldSet(this, _MoralisBDSEthereum_nftDataService, nftDataService, "f");
|
|
69
|
-
__classPrivateFieldSet(this, _MoralisBDSEthereum_explorerService, explorerService, "f");
|
|
58
|
+
constructor(service) {
|
|
59
|
+
super(service);
|
|
60
|
+
_MoralisBDSEthereum_instances.add(this);
|
|
61
|
+
_MoralisBDSEthereum_apiInstance.set(this, void 0);
|
|
70
62
|
}
|
|
71
63
|
getBalance(address) {
|
|
72
64
|
const _super = Object.create(null, {
|
|
73
65
|
getBalance: { get: () => super.getBalance }
|
|
74
66
|
});
|
|
75
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
if (!
|
|
68
|
+
if (!_a.isSupported(this._service.network)) {
|
|
77
69
|
return _super.getBalance.call(this, address);
|
|
78
70
|
}
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
71
|
+
const { data: { balance: nativeBalance }, } = yield __classPrivateFieldGet(this, _MoralisBDSEthereum_instances, "a", _MoralisBDSEthereum_api_get).get(`${address}/balance`);
|
|
72
|
+
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._service.network);
|
|
82
73
|
const balances = [
|
|
83
74
|
{
|
|
84
75
|
amount: ethers_1.ethers.utils.formatUnits(nativeBalance, nativeToken.decimals),
|
|
85
76
|
token: nativeToken,
|
|
86
77
|
},
|
|
87
78
|
];
|
|
88
|
-
const { data: erc20Balances } = yield
|
|
79
|
+
const { data: erc20Balances } = yield __classPrivateFieldGet(this, _MoralisBDSEthereum_instances, "a", _MoralisBDSEthereum_api_get).get(`${address}/erc20`);
|
|
89
80
|
erc20Balances.forEach(balance => {
|
|
90
|
-
var
|
|
81
|
+
var _b;
|
|
91
82
|
if (balance.possible_spam || !balance.decimals || !balance.token_address || !balance.symbol)
|
|
92
83
|
return;
|
|
93
84
|
balances.push({
|
|
94
85
|
amount: ethers_1.ethers.utils.formatUnits(balance.balance, balance.decimals),
|
|
95
|
-
token: this.
|
|
86
|
+
token: this._service.tokenService.normalizeToken({
|
|
96
87
|
decimals: balance.decimals,
|
|
97
88
|
hash: balance.token_address,
|
|
98
|
-
name: (
|
|
89
|
+
name: (_b = balance.name) !== null && _b !== void 0 ? _b : '',
|
|
99
90
|
symbol: balance.symbol,
|
|
100
91
|
}),
|
|
101
92
|
});
|
|
@@ -108,23 +99,22 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
108
99
|
getTokenInfo: { get: () => super.getTokenInfo }
|
|
109
100
|
});
|
|
110
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
if (!
|
|
102
|
+
if (!_a.isSupported(this._service.network)) {
|
|
112
103
|
return _super.getTokenInfo.call(this, hash);
|
|
113
104
|
}
|
|
114
|
-
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this.
|
|
115
|
-
if (this.
|
|
105
|
+
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._service.network);
|
|
106
|
+
if (this._service.tokenService.predicateByHash(nativeAsset, hash))
|
|
116
107
|
return nativeAsset;
|
|
117
108
|
if (this._tokenCache.has(hash)) {
|
|
118
109
|
return this._tokenCache.get(hash);
|
|
119
110
|
}
|
|
120
|
-
const
|
|
121
|
-
const response = yield client.get(`/erc20/metadata`, {
|
|
111
|
+
const response = yield __classPrivateFieldGet(this, _MoralisBDSEthereum_instances, "a", _MoralisBDSEthereum_api_get).get(`/erc20/metadata`, {
|
|
122
112
|
params: {
|
|
123
113
|
addresses: [hash],
|
|
124
114
|
},
|
|
125
115
|
});
|
|
126
116
|
const data = response.data[0];
|
|
127
|
-
const token = this.
|
|
117
|
+
const token = this._service.tokenService.normalizeToken({
|
|
128
118
|
decimals: Number(data.decimals),
|
|
129
119
|
symbol: data.symbol,
|
|
130
120
|
hash,
|
|
@@ -139,14 +129,13 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
139
129
|
getTransaction: { get: () => super.getTransaction }
|
|
140
130
|
});
|
|
141
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
if (!
|
|
132
|
+
if (!_a.isSupported(this._service.network)) {
|
|
143
133
|
return _super.getTransaction.call(this, hash);
|
|
144
134
|
}
|
|
145
|
-
const
|
|
146
|
-
const { data } = yield client.get(`/transaction/${hash}/verbose`);
|
|
135
|
+
const { data } = yield __classPrivateFieldGet(this, _MoralisBDSEthereum_instances, "a", _MoralisBDSEthereum_api_get).get(`/transaction/${hash}/verbose`);
|
|
147
136
|
const transfers = [];
|
|
148
137
|
if (data.value && Number(data.value) > 0) {
|
|
149
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this.
|
|
138
|
+
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._service.network);
|
|
150
139
|
transfers.push({
|
|
151
140
|
amount: ethers_1.ethers.utils.formatUnits(data.value, nativeToken.decimals),
|
|
152
141
|
from: data.from_address,
|
|
@@ -158,15 +147,15 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
158
147
|
}
|
|
159
148
|
if (data.logs) {
|
|
160
149
|
const promises = data.logs.map((log) => __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
var
|
|
150
|
+
var _b, _c, _d, _e;
|
|
162
151
|
if (!log.decoded_event)
|
|
163
152
|
return;
|
|
164
153
|
if (log.decoded_event.label.toLowerCase() !== 'transfer')
|
|
165
154
|
return;
|
|
166
155
|
const contractHash = log.address;
|
|
167
|
-
const amount = (
|
|
168
|
-
const from = (
|
|
169
|
-
const to = (
|
|
156
|
+
const amount = (_b = log.decoded_event.params.find((param) => param.name === 'value')) === null || _b === void 0 ? void 0 : _b.value;
|
|
157
|
+
const from = (_c = log.decoded_event.params.find((param) => param.name === 'from')) === null || _c === void 0 ? void 0 : _c.value;
|
|
158
|
+
const to = (_d = log.decoded_event.params.find((param) => param.name === 'to')) === null || _d === void 0 ? void 0 : _d.value;
|
|
170
159
|
if (!from || !to)
|
|
171
160
|
return;
|
|
172
161
|
if (amount) {
|
|
@@ -179,7 +168,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
179
168
|
type: 'token',
|
|
180
169
|
});
|
|
181
170
|
}
|
|
182
|
-
const tokenHash = (
|
|
171
|
+
const tokenHash = (_e = log.decoded_event.params.find((param) => param.name === 'tokenId')) === null || _e === void 0 ? void 0 : _e.value;
|
|
183
172
|
if (!tokenHash)
|
|
184
173
|
return;
|
|
185
174
|
transfers.push({
|
|
@@ -208,18 +197,17 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
208
197
|
getTransactionsByAddress: { get: () => super.getTransactionsByAddress }
|
|
209
198
|
});
|
|
210
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
-
if (!
|
|
200
|
+
if (!_a.isSupported(this._service.network)) {
|
|
212
201
|
return _super.getTransactionsByAddress.call(this, params);
|
|
213
202
|
}
|
|
214
|
-
const
|
|
215
|
-
const { data } = yield client.get(`/wallets/${params.address}/history`, {
|
|
203
|
+
const { data } = yield __classPrivateFieldGet(this, _MoralisBDSEthereum_instances, "a", _MoralisBDSEthereum_api_get).get(`/wallets/${params.address}/history`, {
|
|
216
204
|
params: {
|
|
217
205
|
limit: 15,
|
|
218
206
|
cursor: params.nextPageParams,
|
|
219
207
|
},
|
|
220
208
|
});
|
|
221
209
|
const transactions = [];
|
|
222
|
-
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this.
|
|
210
|
+
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._service.network);
|
|
223
211
|
const promises = data.result.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
224
212
|
const transfers = [];
|
|
225
213
|
item.native_transfers.forEach(transfer => {
|
|
@@ -240,7 +228,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
240
228
|
from: transfer.from_address,
|
|
241
229
|
to: transfer.to_address,
|
|
242
230
|
type: 'token',
|
|
243
|
-
token: this.
|
|
231
|
+
token: this._service.tokenService.normalizeToken({
|
|
244
232
|
decimals: Number(transfer.token_decimals),
|
|
245
233
|
hash: transfer.address,
|
|
246
234
|
name: transfer.token_name,
|
|
@@ -275,28 +263,28 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
275
263
|
};
|
|
276
264
|
});
|
|
277
265
|
}
|
|
278
|
-
getFullTransactionsByAddress(
|
|
279
|
-
var _b, _c;
|
|
280
|
-
var { nextCursor } = _a, params = __rest(_a, ["nextCursor"]);
|
|
266
|
+
getFullTransactionsByAddress(_b) {
|
|
281
267
|
return __awaiter(this, void 0, void 0, function* () {
|
|
282
|
-
|
|
268
|
+
var _c, _d;
|
|
269
|
+
var { nextCursor } = _b, params = __rest(_b, ["nextCursor"]);
|
|
270
|
+
blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(Object.assign({ service: this._service, supportedNetworksIds: _a.FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS }, params));
|
|
283
271
|
const data = [];
|
|
284
272
|
const response = yield dora_ts_1.api.EthereumREST.getFullTransactionsByAddress({
|
|
285
273
|
address: params.address,
|
|
286
274
|
timestampFrom: params.dateFrom,
|
|
287
275
|
timestampTo: params.dateTo,
|
|
288
|
-
network: this.
|
|
276
|
+
network: this._service.network.id,
|
|
289
277
|
cursor: nextCursor,
|
|
290
|
-
pageLimit: (
|
|
278
|
+
pageLimit: (_c = params.pageSize) !== null && _c !== void 0 ? _c : 50,
|
|
291
279
|
});
|
|
292
|
-
const items = (
|
|
293
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this.
|
|
294
|
-
const addressTemplateUrl =
|
|
295
|
-
const txTemplateUrl =
|
|
296
|
-
const nftTemplateUrl =
|
|
297
|
-
const contractTemplateUrl =
|
|
298
|
-
const itemPromises = items.map((
|
|
299
|
-
var { networkFeeAmount, systemFeeAmount } =
|
|
280
|
+
const items = (_d = response.data) !== null && _d !== void 0 ? _d : [];
|
|
281
|
+
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._service.network);
|
|
282
|
+
const addressTemplateUrl = this._service.explorerService.getAddressTemplateUrl();
|
|
283
|
+
const txTemplateUrl = this._service.explorerService.getTxTemplateUrl();
|
|
284
|
+
const nftTemplateUrl = this._service.explorerService.getNftTemplateUrl();
|
|
285
|
+
const contractTemplateUrl = this._service.explorerService.getContractTemplateUrl();
|
|
286
|
+
const itemPromises = items.map((_b, index) => __awaiter(this, void 0, void 0, function* () {
|
|
287
|
+
var { networkFeeAmount, systemFeeAmount } = _b, item = __rest(_b, ["networkFeeAmount", "systemFeeAmount"]);
|
|
300
288
|
const txId = item.transactionID;
|
|
301
289
|
const newItem = {
|
|
302
290
|
txId,
|
|
@@ -315,26 +303,24 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
315
303
|
type: 'default',
|
|
316
304
|
};
|
|
317
305
|
const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
|
|
318
|
-
var
|
|
319
|
-
let nftEvent;
|
|
320
|
-
let assetEvent;
|
|
306
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
321
307
|
const { methodName, tokenID: tokenHash, contractHash } = event;
|
|
322
|
-
const from = (
|
|
323
|
-
const to = (
|
|
324
|
-
const standard = (
|
|
325
|
-
const isErc1155 =
|
|
326
|
-
const isErc721 =
|
|
327
|
-
const isErc20 =
|
|
308
|
+
const from = (_b = event.from) !== null && _b !== void 0 ? _b : undefined;
|
|
309
|
+
const to = (_c = event.to) !== null && _c !== void 0 ? _c : undefined;
|
|
310
|
+
const standard = (_f = (_e = (_d = event.supportedStandards) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.toLowerCase()) !== null && _f !== void 0 ? _f : '';
|
|
311
|
+
const isErc1155 = _a.FULL_TRANSACTIONS_ERC1155_STANDARDS.includes(standard);
|
|
312
|
+
const isErc721 = _a.FULL_TRANSACTIONS_ERC721_STANDARDS.includes(standard);
|
|
313
|
+
const isErc20 = _a.FULL_TRANSACTIONS_ERC20_STANDARDS.includes(standard);
|
|
328
314
|
const isNft = (isErc1155 || isErc721) && !!tokenHash;
|
|
329
315
|
const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
|
|
330
316
|
const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
|
|
331
317
|
const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
|
|
332
318
|
if (isNft) {
|
|
333
|
-
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() =>
|
|
319
|
+
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this._service.nftDataService.getNft({ collectionHash: contractHash, tokenHash }));
|
|
334
320
|
const nftUrl = contractHash
|
|
335
321
|
? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{collectionHash}', contractHash).replace('{tokenHash}', tokenHash)
|
|
336
322
|
: undefined;
|
|
337
|
-
|
|
323
|
+
newItem.events.splice(eventIndex, 0, {
|
|
338
324
|
eventType: 'nft',
|
|
339
325
|
amount: undefined,
|
|
340
326
|
methodName,
|
|
@@ -349,28 +335,26 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
349
335
|
nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
|
|
350
336
|
nftUrl,
|
|
351
337
|
name: nft === null || nft === void 0 ? void 0 : nft.name,
|
|
352
|
-
collectionName: (
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
else {
|
|
356
|
-
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
|
|
357
|
-
assetEvent = {
|
|
358
|
-
eventType: 'token',
|
|
359
|
-
amount: event.amount
|
|
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 })
|
|
361
|
-
: undefined,
|
|
362
|
-
methodName,
|
|
363
|
-
from,
|
|
364
|
-
fromUrl,
|
|
365
|
-
to,
|
|
366
|
-
toUrl,
|
|
367
|
-
contractHash,
|
|
368
|
-
contractHashUrl,
|
|
369
|
-
token: token !== null && token !== void 0 ? token : undefined,
|
|
370
|
-
tokenType: isErc20 ? 'erc-20' : 'generic',
|
|
371
|
-
};
|
|
338
|
+
collectionName: (_g = nft === null || nft === void 0 ? void 0 : nft.collection) === null || _g === void 0 ? void 0 : _g.name,
|
|
339
|
+
});
|
|
340
|
+
return;
|
|
372
341
|
}
|
|
373
|
-
|
|
342
|
+
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
|
|
343
|
+
newItem.events.splice(eventIndex, 0, {
|
|
344
|
+
eventType: 'token',
|
|
345
|
+
amount: event.amount
|
|
346
|
+
? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_h = token === null || token === void 0 ? void 0 : token.decimals) !== null && _h !== void 0 ? _h : event.tokenDecimals })
|
|
347
|
+
: undefined,
|
|
348
|
+
methodName,
|
|
349
|
+
from,
|
|
350
|
+
fromUrl,
|
|
351
|
+
to,
|
|
352
|
+
toUrl,
|
|
353
|
+
contractHash,
|
|
354
|
+
contractHashUrl,
|
|
355
|
+
token: token !== null && token !== void 0 ? token : undefined,
|
|
356
|
+
tokenType: isErc20 ? 'erc-20' : 'generic',
|
|
357
|
+
});
|
|
374
358
|
}));
|
|
375
359
|
yield Promise.allSettled(eventPromises);
|
|
376
360
|
data.splice(index, 0, newItem);
|
|
@@ -381,12 +365,12 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
381
365
|
}
|
|
382
366
|
exportFullTransactionsByAddress(params) {
|
|
383
367
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384
|
-
this.
|
|
368
|
+
blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(Object.assign({ service: this._service, supportedNetworksIds: _a.FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS }, params));
|
|
385
369
|
return yield dora_ts_1.api.EthereumREST.exportFullTransactionsByAddress({
|
|
386
370
|
address: params.address,
|
|
387
371
|
timestampFrom: params.dateFrom,
|
|
388
372
|
timestampTo: params.dateTo,
|
|
389
|
-
network: this.
|
|
373
|
+
network: this._service.network.id,
|
|
390
374
|
});
|
|
391
375
|
});
|
|
392
376
|
}
|
|
@@ -395,27 +379,26 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
395
379
|
getContract: { get: () => super.getContract }
|
|
396
380
|
});
|
|
397
381
|
return __awaiter(this, void 0, void 0, function* () {
|
|
398
|
-
if (!
|
|
382
|
+
if (!_a.isSupported(this._service.network)) {
|
|
399
383
|
return _super.getContract.call(this, hash);
|
|
400
384
|
}
|
|
401
385
|
try {
|
|
402
|
-
const
|
|
403
|
-
const { data } = yield client.get(`erc20/metadata`, {
|
|
386
|
+
const { data } = yield __classPrivateFieldGet(this, _MoralisBDSEthereum_instances, "a", _MoralisBDSEthereum_api_get).get(`erc20/metadata`, {
|
|
404
387
|
params: {
|
|
405
388
|
addresses: [hash],
|
|
406
389
|
},
|
|
407
390
|
});
|
|
408
391
|
const methods = [];
|
|
409
392
|
ERC20_1.ERC20_ABI.forEach(abi => {
|
|
410
|
-
var
|
|
393
|
+
var _b, _c;
|
|
411
394
|
if (abi.type !== 'function')
|
|
412
395
|
return;
|
|
413
|
-
const parameters = (
|
|
396
|
+
const parameters = (_b = abi.inputs) === null || _b === void 0 ? void 0 : _b.map(param => ({
|
|
414
397
|
name: param.name,
|
|
415
398
|
type: param.type,
|
|
416
399
|
}));
|
|
417
400
|
methods.push({
|
|
418
|
-
name: (
|
|
401
|
+
name: (_c = abi.name) !== null && _c !== void 0 ? _c : '',
|
|
419
402
|
parameters: parameters !== null && parameters !== void 0 ? parameters : [],
|
|
420
403
|
});
|
|
421
404
|
});
|
|
@@ -425,53 +408,29 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
425
408
|
methods,
|
|
426
409
|
};
|
|
427
410
|
}
|
|
428
|
-
catch (
|
|
411
|
+
catch (_b) {
|
|
429
412
|
throw new Error('Contract not found or not an ERC20 token');
|
|
430
413
|
}
|
|
431
414
|
});
|
|
432
415
|
}
|
|
433
416
|
}
|
|
434
417
|
exports.MoralisBDSEthereum = MoralisBDSEthereum;
|
|
435
|
-
|
|
418
|
+
_a = MoralisBDSEthereum, _MoralisBDSEthereum_apiInstance = new WeakMap(), _MoralisBDSEthereum_instances = new WeakSet(), _MoralisBDSEthereum_api_get = function _MoralisBDSEthereum_api_get() {
|
|
419
|
+
if (!__classPrivateFieldGet(this, _MoralisBDSEthereum_apiInstance, "f")) {
|
|
420
|
+
__classPrivateFieldSet(this, _MoralisBDSEthereum_apiInstance, _a.getClient(this._service.network), "f");
|
|
421
|
+
}
|
|
422
|
+
return __classPrivateFieldGet(this, _MoralisBDSEthereum_apiInstance, "f");
|
|
423
|
+
};
|
|
436
424
|
MoralisBDSEthereum.BASE_URL = `${blockchain_service_1.BSCommonConstants.DORA_URL}/api/v2/meta`;
|
|
437
|
-
MoralisBDSEthereum.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
'56',
|
|
444
|
-
'
|
|
445
|
-
|
|
446
|
-
'
|
|
447
|
-
|
|
448
|
-
'84532',
|
|
449
|
-
'10',
|
|
450
|
-
'11155420',
|
|
451
|
-
'59144',
|
|
452
|
-
'59141',
|
|
453
|
-
'43114',
|
|
454
|
-
'250',
|
|
455
|
-
'4002',
|
|
456
|
-
'25',
|
|
457
|
-
'11297108109',
|
|
458
|
-
'2020',
|
|
459
|
-
'100',
|
|
460
|
-
'10200',
|
|
461
|
-
'88888',
|
|
462
|
-
'88882',
|
|
463
|
-
'369',
|
|
464
|
-
'1284',
|
|
465
|
-
'1285',
|
|
466
|
-
'1287',
|
|
467
|
-
'81457',
|
|
468
|
-
'168587773',
|
|
469
|
-
'324',
|
|
470
|
-
'300',
|
|
471
|
-
'5000',
|
|
472
|
-
'5003',
|
|
473
|
-
'1101',
|
|
474
|
-
'2442',
|
|
475
|
-
'7000',
|
|
476
|
-
'7001',
|
|
425
|
+
MoralisBDSEthereum.FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS = ['1', '42161', '8453', '137'];
|
|
426
|
+
MoralisBDSEthereum.FULL_TRANSACTIONS_ERC721_STANDARDS = ['erc721', 'erc-721'];
|
|
427
|
+
MoralisBDSEthereum.FULL_TRANSACTIONS_ERC1155_STANDARDS = ['erc1155', 'erc-1155'];
|
|
428
|
+
MoralisBDSEthereum.FULL_TRANSACTIONS_ERC20_STANDARDS = ['erc20', 'erc-20'];
|
|
429
|
+
// prettier-ignore
|
|
430
|
+
MoralisBDSEthereum.MORALIS_SUPPORTED_NETWORKS_IDS = [
|
|
431
|
+
'1', '11155111', '17000', '137', '80002', '56', '97', '42161', '421614',
|
|
432
|
+
'8453', '84532', '10', '11155420', '59144', '59141', '43114', '250',
|
|
433
|
+
'4002', '25', '11297108109', '2020', '100', '10200', '88888', '88882',
|
|
434
|
+
'369', '1284', '1285', '1287', '81457', '168587773', '324', '300',
|
|
435
|
+
'5000', '5003', '1101', '2442', '7000', '7001'
|
|
477
436
|
];
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare class RpcBDSEthereum<
|
|
4
|
-
|
|
5
|
-
readonly
|
|
6
|
-
_tokenCache: Map<string,
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
9
|
-
getTransaction(hash: string): Promise<
|
|
10
|
-
getTransactionsByAddress(_params:
|
|
11
|
-
getFullTransactionsByAddress(_params:
|
|
12
|
-
exportFullTransactionsByAddress(_params:
|
|
1
|
+
import { TBalanceResponse, ContractResponse, TExportTransactionsByAddressParams, TFullTransactionsByAddressParams, TFullTransactionsByAddressResponse, IBlockchainDataService, TBSNetworkId, TBSToken, TTransactionResponse, TTransactionsByAddressParams, TTransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { IBSEthereum } from '../../types';
|
|
3
|
+
export declare class RpcBDSEthereum<N extends string, A extends TBSNetworkId, S extends IBSEthereum<N, A> = IBSEthereum<N, A>> implements IBlockchainDataService {
|
|
4
|
+
#private;
|
|
5
|
+
readonly maxTimeToConfirmTransactionInMs: number;
|
|
6
|
+
readonly _tokenCache: Map<string, TBSToken>;
|
|
7
|
+
readonly _service: S;
|
|
8
|
+
constructor(service: S);
|
|
9
|
+
getTransaction(hash: string): Promise<TTransactionResponse>;
|
|
10
|
+
getTransactionsByAddress(_params: TTransactionsByAddressParams): Promise<TTransactionsByAddressResponse>;
|
|
11
|
+
getFullTransactionsByAddress(_params: TFullTransactionsByAddressParams): Promise<TFullTransactionsByAddressResponse>;
|
|
12
|
+
exportFullTransactionsByAddress(_params: TExportTransactionsByAddressParams): Promise<string>;
|
|
13
13
|
getContract(_hash: string): Promise<ContractResponse>;
|
|
14
|
-
getTokenInfo(hash: string): Promise<
|
|
15
|
-
getBalance(address: string): Promise<
|
|
14
|
+
getTokenInfo(hash: string): Promise<TBSToken>;
|
|
15
|
+
getBalance(address: string): Promise<TBalanceResponse[]>;
|
|
16
16
|
getBlockHeight(): Promise<number>;
|
|
17
|
-
getRpcList(): Promise<RpcResponse[]>;
|
|
18
17
|
}
|