@cityofzion/bs-ethereum 2.12.8 → 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.
- package/dist/BSEthereum.d.ts +3 -2
- package/dist/BSEthereum.js +8 -6
- package/dist/helpers/BSEthereumHelper.d.ts +2 -1
- package/dist/helpers/BSEthereumHelper.js +4 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/services/blockchain-data/DoraBDSEthereum.d.ts +6 -5
- package/dist/services/blockchain-data/DoraBDSEthereum.js +7 -127
- package/dist/services/blockchain-data/MoralisBDSEthereum.d.ts +3 -2
- package/dist/services/blockchain-data/MoralisBDSEthereum.js +121 -15
- package/dist/services/blockchain-data/RpcBDSEthereum.d.ts +4 -3
- package/dist/services/blockchain-data/RpcBDSEthereum.js +5 -4
- package/dist/services/exchange-data/MoralisEDSEthereum.d.ts +2 -2
- package/dist/services/exchange-data/MoralisEDSEthereum.js +8 -7
- package/dist/services/explorer/BlockscoutESEthereum.d.ts +2 -2
- package/dist/services/explorer/BlockscoutESEthereum.js +9 -8
- package/dist/services/nft-data/GhostMarketNDSEthereum.d.ts +1 -1
- package/dist/services/nft-data/GhostMarketNDSEthereum.js +9 -7
- package/dist/services/nft-data/RpcNDSEthereum.d.ts +1 -1
- package/dist/services/nft-data/RpcNDSEthereum.js +3 -3
- package/dist/services/token/TokenServiceEthereum.d.ts +4 -0
- package/dist/{helpers/BSEthereumTokenHelper.js → services/token/TokenServiceEthereum.js} +5 -5
- package/package.json +2 -2
- package/dist/helpers/BSEthereumTokenHelper.d.ts +0 -4
package/dist/BSEthereum.d.ts
CHANGED
|
@@ -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>;
|
package/dist/BSEthereum.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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.
|
|
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 =
|
|
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
|
|
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
|
-
|
|
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,11 +1,12 @@
|
|
|
1
1
|
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
2
|
-
import {
|
|
3
|
-
import { GetFullTransactionsByAddressResponse } from '@cityofzion/dora-ts/dist/interfaces/api/common';
|
|
2
|
+
import { FullTransactionsByAddressParams, Network, NetworkId, TokenService } from '@cityofzion/blockchain-service';
|
|
4
3
|
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
5
4
|
export declare class DoraBDSEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> extends RpcBDSEthereum {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
readonly _supportedErc721Standards: string[];
|
|
6
|
+
readonly _supportedErc1155Standards: string[];
|
|
7
|
+
readonly _supportedErc20Standards: string[];
|
|
8
|
+
readonly _supportedFullTransactionsByAddressNetworks: BSNetworkId[];
|
|
9
|
+
constructor(network: Network<BSNetworkId>, supportedFullTransactionsByAddressNetworks: BSNetworkId[], tokenService: TokenService);
|
|
9
10
|
_validateFullTransactionsByAddressParams(params: Pick<FullTransactionsByAddressParams, 'address' | 'dateFrom' | 'dateTo'>): void;
|
|
10
11
|
_validateGetFullTransactionsByAddressParams({ pageSize, ...params }: Pick<FullTransactionsByAddressParams, 'address' | 'dateFrom' | 'dateTo' | 'pageSize'>): void;
|
|
11
12
|
}
|
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
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
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
23
3
|
var t = {};
|
|
24
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -30,120 +10,21 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
30
10
|
}
|
|
31
11
|
return t;
|
|
32
12
|
};
|
|
33
|
-
var _DoraBDSEthereum_supportedErc721Standards, _DoraBDSEthereum_supportedErc1155Standards, _DoraBDSEthereum_supportedErc20Standards, _DoraBDSEthereum_supportedFullTransactionsByAddressNetworks, _DoraBDSEthereum_nftDataService, _DoraBDSEthereum_explorerService;
|
|
34
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
14
|
exports.DoraBDSEthereum = void 0;
|
|
36
15
|
const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
37
16
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
38
17
|
const ethers_1 = require("ethers");
|
|
39
|
-
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
40
18
|
class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
41
|
-
constructor(network, supportedFullTransactionsByAddressNetworks,
|
|
42
|
-
super(network);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_DoraBDSEthereum_nftDataService.set(this, void 0);
|
|
48
|
-
_DoraBDSEthereum_explorerService.set(this, void 0);
|
|
49
|
-
__classPrivateFieldSet(this, _DoraBDSEthereum_supportedFullTransactionsByAddressNetworks, supportedFullTransactionsByAddressNetworks, "f");
|
|
50
|
-
__classPrivateFieldSet(this, _DoraBDSEthereum_nftDataService, nftDataService, "f");
|
|
51
|
-
__classPrivateFieldSet(this, _DoraBDSEthereum_explorerService, explorerService, "f");
|
|
52
|
-
}
|
|
53
|
-
_transformFullTransactionsByAddressResponse(_a) {
|
|
54
|
-
var _b;
|
|
55
|
-
var { nextCursor } = _a, response = __rest(_a, ["nextCursor"]);
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const data = [];
|
|
58
|
-
const items = (_b = response.data) !== null && _b !== void 0 ? _b : [];
|
|
59
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
60
|
-
const addressTemplateUrl = __classPrivateFieldGet(this, _DoraBDSEthereum_explorerService, "f").getAddressTemplateUrl();
|
|
61
|
-
const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSEthereum_explorerService, "f").getTxTemplateUrl();
|
|
62
|
-
const nftTemplateUrl = __classPrivateFieldGet(this, _DoraBDSEthereum_explorerService, "f").getNftTemplateUrl();
|
|
63
|
-
const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSEthereum_explorerService, "f").getContractTemplateUrl();
|
|
64
|
-
const itemPromises = items.map((_c) => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
var { networkFeeAmount, systemFeeAmount } = _c, item = __rest(_c, ["networkFeeAmount", "systemFeeAmount"]);
|
|
66
|
-
const txId = item.transactionID;
|
|
67
|
-
const newItem = {
|
|
68
|
-
txId,
|
|
69
|
-
txIdUrl: txId ? txTemplateUrl === null || txTemplateUrl === void 0 ? void 0 : txTemplateUrl.replace('{txId}', txId) : undefined,
|
|
70
|
-
block: item.block,
|
|
71
|
-
date: item.date,
|
|
72
|
-
invocationCount: item.invocationCount,
|
|
73
|
-
notificationCount: item.notificationCount,
|
|
74
|
-
networkFeeAmount: networkFeeAmount
|
|
75
|
-
? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: nativeToken.decimals })
|
|
76
|
-
: undefined,
|
|
77
|
-
systemFeeAmount: systemFeeAmount
|
|
78
|
-
? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: nativeToken.decimals })
|
|
79
|
-
: undefined,
|
|
80
|
-
events: [],
|
|
81
|
-
};
|
|
82
|
-
const eventPromises = item.events.map((event) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
var _d, _e, _f, _g, _h, _j;
|
|
84
|
-
let nftEvent;
|
|
85
|
-
let assetEvent;
|
|
86
|
-
const { methodName, tokenID: tokenId, contractHash: hash } = event;
|
|
87
|
-
const from = (_d = event.from) !== null && _d !== void 0 ? _d : undefined;
|
|
88
|
-
const to = (_e = event.to) !== null && _e !== void 0 ? _e : undefined;
|
|
89
|
-
const standard = (_h = (_g = (_f = event.supportedStandards) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.toLowerCase()) !== null && _h !== void 0 ? _h : '';
|
|
90
|
-
const isErc1155 = __classPrivateFieldGet(this, _DoraBDSEthereum_supportedErc1155Standards, "f").includes(standard);
|
|
91
|
-
const isErc721 = __classPrivateFieldGet(this, _DoraBDSEthereum_supportedErc721Standards, "f").includes(standard);
|
|
92
|
-
const isErc20 = __classPrivateFieldGet(this, _DoraBDSEthereum_supportedErc20Standards, "f").includes(standard);
|
|
93
|
-
const isNft = (isErc1155 || isErc721) && !!tokenId;
|
|
94
|
-
const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
|
|
95
|
-
const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
|
|
96
|
-
const hashUrl = hash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', hash) : undefined;
|
|
97
|
-
if (isNft) {
|
|
98
|
-
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraBDSEthereum_nftDataService, "f").getNft({ contractHash: hash, tokenId }));
|
|
99
|
-
const nftUrl = hash ? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{hash}', hash).replace('{tokenId}', tokenId) : undefined;
|
|
100
|
-
nftEvent = {
|
|
101
|
-
eventType: 'nft',
|
|
102
|
-
amount: undefined,
|
|
103
|
-
methodName,
|
|
104
|
-
from,
|
|
105
|
-
fromUrl,
|
|
106
|
-
to,
|
|
107
|
-
toUrl,
|
|
108
|
-
hash,
|
|
109
|
-
hashUrl,
|
|
110
|
-
tokenId,
|
|
111
|
-
tokenType: isErc1155 ? 'erc-1155' : 'erc-721',
|
|
112
|
-
nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
|
|
113
|
-
nftUrl,
|
|
114
|
-
name: nft === null || nft === void 0 ? void 0 : nft.name,
|
|
115
|
-
collectionName: nft === null || nft === void 0 ? void 0 : nft.collectionName,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(hash));
|
|
120
|
-
assetEvent = {
|
|
121
|
-
eventType: 'token',
|
|
122
|
-
amount: event.amount
|
|
123
|
-
? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_j = token === null || token === void 0 ? void 0 : token.decimals) !== null && _j !== void 0 ? _j : event.tokenDecimals })
|
|
124
|
-
: undefined,
|
|
125
|
-
methodName,
|
|
126
|
-
from,
|
|
127
|
-
fromUrl,
|
|
128
|
-
to,
|
|
129
|
-
toUrl,
|
|
130
|
-
hash,
|
|
131
|
-
hashUrl,
|
|
132
|
-
token: token !== null && token !== void 0 ? token : undefined,
|
|
133
|
-
tokenType: isErc20 ? 'erc-20' : 'generic',
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
newItem.events.push(isNft ? nftEvent : assetEvent);
|
|
137
|
-
}));
|
|
138
|
-
yield Promise.allSettled(eventPromises);
|
|
139
|
-
data.push(newItem);
|
|
140
|
-
}));
|
|
141
|
-
yield Promise.allSettled(itemPromises);
|
|
142
|
-
return { nextCursor, data };
|
|
143
|
-
});
|
|
19
|
+
constructor(network, supportedFullTransactionsByAddressNetworks, tokenService) {
|
|
20
|
+
super(network, tokenService);
|
|
21
|
+
this._supportedErc721Standards = ['erc721', 'erc-721'];
|
|
22
|
+
this._supportedErc1155Standards = ['erc1155', 'erc-1155'];
|
|
23
|
+
this._supportedErc20Standards = ['erc20', 'erc-20'];
|
|
24
|
+
this._supportedFullTransactionsByAddressNetworks = supportedFullTransactionsByAddressNetworks;
|
|
144
25
|
}
|
|
145
26
|
_validateFullTransactionsByAddressParams(params) {
|
|
146
|
-
if (!
|
|
27
|
+
if (!this._supportedFullTransactionsByAddressNetworks.includes(this._network.id))
|
|
147
28
|
throw new Error('This network is not supported');
|
|
148
29
|
blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(params);
|
|
149
30
|
if (!ethers_1.ethers.utils.isAddress(params.address))
|
|
@@ -157,4 +38,3 @@ class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
157
38
|
}
|
|
158
39
|
}
|
|
159
40
|
exports.DoraBDSEthereum = DoraBDSEthereum;
|
|
160
|
-
_DoraBDSEthereum_supportedErc721Standards = new WeakMap(), _DoraBDSEthereum_supportedErc1155Standards = new WeakMap(), _DoraBDSEthereum_supportedErc20Standards = new WeakMap(), _DoraBDSEthereum_supportedFullTransactionsByAddressNetworks = new WeakMap(), _DoraBDSEthereum_nftDataService = new WeakMap(), _DoraBDSEthereum_explorerService = new WeakMap();
|
|
@@ -1,12 +1,13 @@
|
|
|
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 {
|
|
5
|
+
#private;
|
|
5
6
|
static BASE_URL: string;
|
|
6
7
|
static SUPPORTED_CHAINS: string[];
|
|
7
8
|
static getClient(network: Network<BSEthereumNetworkId>): import("axios").AxiosInstance;
|
|
8
9
|
static isSupported(network: Network<BSEthereumNetworkId>): boolean;
|
|
9
|
-
constructor(network: Network<BSEthereumNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService);
|
|
10
|
+
constructor(network: Network<BSEthereumNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService, tokenService: TokenService);
|
|
10
11
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
11
12
|
getTokenInfo(hash: string): Promise<Token>;
|
|
12
13
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
@@ -8,6 +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 __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
|
+
};
|
|
11
22
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
23
|
var t = {};
|
|
13
24
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -22,6 +33,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
33
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
34
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
35
|
};
|
|
36
|
+
var _MoralisBDSEthereum_nftDataService, _MoralisBDSEthereum_explorerService;
|
|
25
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
38
|
exports.MoralisBDSEthereum = void 0;
|
|
27
39
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
@@ -32,7 +44,6 @@ const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
|
32
44
|
const ERC20_1 = require("../../assets/abis/ERC20");
|
|
33
45
|
const dora_ts_1 = require("@cityofzion/dora-ts");
|
|
34
46
|
const DoraBDSEthereum_1 = require("./DoraBDSEthereum");
|
|
35
|
-
const BSEthereumTokenHelper_1 = require("../../helpers/BSEthereumTokenHelper");
|
|
36
47
|
class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
37
48
|
static getClient(network) {
|
|
38
49
|
return axios_1.default.create({
|
|
@@ -45,13 +56,17 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
45
56
|
static isSupported(network) {
|
|
46
57
|
return MoralisBDSEthereum.SUPPORTED_CHAINS.includes(network.id);
|
|
47
58
|
}
|
|
48
|
-
constructor(network, nftDataService, explorerService) {
|
|
59
|
+
constructor(network, nftDataService, explorerService, tokenService) {
|
|
49
60
|
super(network, [
|
|
50
61
|
BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID,
|
|
51
62
|
BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID,
|
|
52
63
|
BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID,
|
|
53
64
|
BSEthereumConstants_1.BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID,
|
|
54
|
-
],
|
|
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");
|
|
55
70
|
}
|
|
56
71
|
getBalance(address) {
|
|
57
72
|
const _super = Object.create(null, {
|
|
@@ -77,7 +92,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
77
92
|
return;
|
|
78
93
|
balances.push({
|
|
79
94
|
amount: ethers_1.ethers.utils.formatUnits(balance.balance, balance.decimals),
|
|
80
|
-
token:
|
|
95
|
+
token: this._tokenService.normalizeToken({
|
|
81
96
|
decimals: balance.decimals,
|
|
82
97
|
hash: balance.token_address,
|
|
83
98
|
name: (_a = balance.name) !== null && _a !== void 0 ? _a : '',
|
|
@@ -97,7 +112,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
97
112
|
return _super.getTokenInfo.call(this, hash);
|
|
98
113
|
}
|
|
99
114
|
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
100
|
-
if (
|
|
115
|
+
if (this._tokenService.predicateByHash(nativeAsset)({ hash }))
|
|
101
116
|
return nativeAsset;
|
|
102
117
|
if (this._tokenCache.has(hash)) {
|
|
103
118
|
return this._tokenCache.get(hash);
|
|
@@ -109,7 +124,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
109
124
|
},
|
|
110
125
|
});
|
|
111
126
|
const data = response.data[0];
|
|
112
|
-
const token =
|
|
127
|
+
const token = this._tokenService.normalizeToken({
|
|
113
128
|
decimals: Number(data.decimals),
|
|
114
129
|
symbol: data.symbol,
|
|
115
130
|
hash,
|
|
@@ -164,12 +179,12 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
164
179
|
type: 'token',
|
|
165
180
|
});
|
|
166
181
|
}
|
|
167
|
-
const
|
|
168
|
-
if (!
|
|
182
|
+
const tokenHash = (_d = log.decoded_event.params.find((param) => param.name === 'tokenId')) === null || _d === void 0 ? void 0 : _d.value;
|
|
183
|
+
if (!tokenHash)
|
|
169
184
|
return;
|
|
170
185
|
transfers.push({
|
|
171
|
-
contractHash,
|
|
172
|
-
|
|
186
|
+
collectionHash: contractHash,
|
|
187
|
+
tokenHash,
|
|
173
188
|
from,
|
|
174
189
|
to,
|
|
175
190
|
type: 'nft',
|
|
@@ -184,6 +199,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
184
199
|
time: new Date(data.block_timestamp).getTime() / 1000,
|
|
185
200
|
transfers,
|
|
186
201
|
fee: data.transaction_fee,
|
|
202
|
+
type: 'default',
|
|
187
203
|
};
|
|
188
204
|
});
|
|
189
205
|
}
|
|
@@ -224,7 +240,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
224
240
|
from: transfer.from_address,
|
|
225
241
|
to: transfer.to_address,
|
|
226
242
|
type: 'token',
|
|
227
|
-
token:
|
|
243
|
+
token: this._tokenService.normalizeToken({
|
|
228
244
|
decimals: Number(transfer.token_decimals),
|
|
229
245
|
hash: transfer.address,
|
|
230
246
|
name: transfer.token_name,
|
|
@@ -235,8 +251,8 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
235
251
|
});
|
|
236
252
|
item.nft_transfers.forEach(transfer => {
|
|
237
253
|
transfers.push({
|
|
238
|
-
|
|
239
|
-
|
|
254
|
+
collectionHash: transfer.token_address,
|
|
255
|
+
tokenHash: transfer.token_id,
|
|
240
256
|
from: transfer.from_address,
|
|
241
257
|
to: transfer.to_address,
|
|
242
258
|
type: 'nft',
|
|
@@ -249,6 +265,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
249
265
|
time: new Date(item.block_timestamp).getTime() / 1000,
|
|
250
266
|
transfers,
|
|
251
267
|
fee: item.transaction_fee,
|
|
268
|
+
type: 'default',
|
|
252
269
|
});
|
|
253
270
|
}));
|
|
254
271
|
yield Promise.allSettled(promises);
|
|
@@ -259,10 +276,11 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
259
276
|
});
|
|
260
277
|
}
|
|
261
278
|
getFullTransactionsByAddress(_a) {
|
|
262
|
-
var _b;
|
|
279
|
+
var _b, _c;
|
|
263
280
|
var { nextCursor } = _a, params = __rest(_a, ["nextCursor"]);
|
|
264
281
|
return __awaiter(this, void 0, void 0, function* () {
|
|
265
282
|
this._validateGetFullTransactionsByAddressParams(params);
|
|
283
|
+
const data = [];
|
|
266
284
|
const response = yield dora_ts_1.api.EthereumREST.getFullTransactionsByAddress({
|
|
267
285
|
address: params.address,
|
|
268
286
|
timestampFrom: params.dateFrom,
|
|
@@ -271,7 +289,94 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
271
289
|
cursor: nextCursor,
|
|
272
290
|
pageLimit: (_b = params.pageSize) !== null && _b !== void 0 ? _b : 50,
|
|
273
291
|
});
|
|
274
|
-
|
|
292
|
+
const items = (_c = response.data) !== null && _c !== void 0 ? _c : [];
|
|
293
|
+
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
294
|
+
const addressTemplateUrl = __classPrivateFieldGet(this, _MoralisBDSEthereum_explorerService, "f").getAddressTemplateUrl();
|
|
295
|
+
const txTemplateUrl = __classPrivateFieldGet(this, _MoralisBDSEthereum_explorerService, "f").getTxTemplateUrl();
|
|
296
|
+
const nftTemplateUrl = __classPrivateFieldGet(this, _MoralisBDSEthereum_explorerService, "f").getNftTemplateUrl();
|
|
297
|
+
const contractTemplateUrl = __classPrivateFieldGet(this, _MoralisBDSEthereum_explorerService, "f").getContractTemplateUrl();
|
|
298
|
+
const itemPromises = items.map((_d, index) => __awaiter(this, void 0, void 0, function* () {
|
|
299
|
+
var { networkFeeAmount, systemFeeAmount } = _d, item = __rest(_d, ["networkFeeAmount", "systemFeeAmount"]);
|
|
300
|
+
const txId = item.transactionID;
|
|
301
|
+
const newItem = {
|
|
302
|
+
txId,
|
|
303
|
+
txIdUrl: txId ? txTemplateUrl === null || txTemplateUrl === void 0 ? void 0 : txTemplateUrl.replace('{txId}', txId) : undefined,
|
|
304
|
+
block: item.block,
|
|
305
|
+
date: item.date,
|
|
306
|
+
invocationCount: item.invocationCount,
|
|
307
|
+
notificationCount: item.notificationCount,
|
|
308
|
+
networkFeeAmount: networkFeeAmount
|
|
309
|
+
? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: nativeToken.decimals })
|
|
310
|
+
: undefined,
|
|
311
|
+
systemFeeAmount: systemFeeAmount
|
|
312
|
+
? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: nativeToken.decimals })
|
|
313
|
+
: undefined,
|
|
314
|
+
events: [],
|
|
315
|
+
type: 'default',
|
|
316
|
+
};
|
|
317
|
+
const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
|
|
318
|
+
var _e, _f, _g, _h, _j, _k, _l;
|
|
319
|
+
let nftEvent;
|
|
320
|
+
let assetEvent;
|
|
321
|
+
const { methodName, tokenID: tokenHash, contractHash } = event;
|
|
322
|
+
const from = (_e = event.from) !== null && _e !== void 0 ? _e : undefined;
|
|
323
|
+
const to = (_f = event.to) !== null && _f !== void 0 ? _f : undefined;
|
|
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 : '';
|
|
325
|
+
const isErc1155 = this._supportedErc1155Standards.includes(standard);
|
|
326
|
+
const isErc721 = this._supportedErc721Standards.includes(standard);
|
|
327
|
+
const isErc20 = this._supportedErc20Standards.includes(standard);
|
|
328
|
+
const isNft = (isErc1155 || isErc721) && !!tokenHash;
|
|
329
|
+
const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
|
|
330
|
+
const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
|
|
331
|
+
const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
|
|
332
|
+
if (isNft) {
|
|
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;
|
|
337
|
+
nftEvent = {
|
|
338
|
+
eventType: 'nft',
|
|
339
|
+
amount: undefined,
|
|
340
|
+
methodName,
|
|
341
|
+
from,
|
|
342
|
+
fromUrl,
|
|
343
|
+
to,
|
|
344
|
+
toUrl,
|
|
345
|
+
collectionHash: contractHash,
|
|
346
|
+
collectionHashUrl: contractHashUrl,
|
|
347
|
+
tokenHash,
|
|
348
|
+
tokenType: isErc1155 ? 'erc-1155' : 'erc-721',
|
|
349
|
+
nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
|
|
350
|
+
nftUrl,
|
|
351
|
+
name: nft === null || nft === void 0 ? void 0 : nft.name,
|
|
352
|
+
collectionName: (_k = nft === null || nft === void 0 ? void 0 : nft.collection) === null || _k === void 0 ? void 0 : _k.name,
|
|
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
|
+
};
|
|
372
|
+
}
|
|
373
|
+
newItem.events.splice(eventIndex, 0, isNft ? nftEvent : assetEvent);
|
|
374
|
+
}));
|
|
375
|
+
yield Promise.allSettled(eventPromises);
|
|
376
|
+
data.splice(index, 0, newItem);
|
|
377
|
+
}));
|
|
378
|
+
yield Promise.allSettled(itemPromises);
|
|
379
|
+
return { nextCursor: response.nextCursor, data };
|
|
275
380
|
});
|
|
276
381
|
}
|
|
277
382
|
exportFullTransactionsByAddress(params) {
|
|
@@ -327,6 +432,7 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
327
432
|
}
|
|
328
433
|
}
|
|
329
434
|
exports.MoralisBDSEthereum = MoralisBDSEthereum;
|
|
435
|
+
_MoralisBDSEthereum_nftDataService = new WeakMap(), _MoralisBDSEthereum_explorerService = new WeakMap();
|
|
330
436
|
MoralisBDSEthereum.BASE_URL = `${blockchain_service_1.BSCommonConstants.DORA_URL}/api/v2/meta`;
|
|
331
437
|
MoralisBDSEthereum.SUPPORTED_CHAINS = [
|
|
332
438
|
BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID,
|
|
@@ -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* () {
|
|
@@ -45,6 +45,7 @@ class RpcBDSEthereum {
|
|
|
45
45
|
},
|
|
46
46
|
],
|
|
47
47
|
notifications: [],
|
|
48
|
+
type: 'default',
|
|
48
49
|
};
|
|
49
50
|
});
|
|
50
51
|
}
|
|
@@ -71,7 +72,7 @@ class RpcBDSEthereum {
|
|
|
71
72
|
getTokenInfo(hash) {
|
|
72
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
74
|
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
74
|
-
if (
|
|
75
|
+
if (this._tokenService.predicateByHash(nativeAsset)({ hash }))
|
|
75
76
|
return nativeAsset;
|
|
76
77
|
if (this._tokenCache.has(hash)) {
|
|
77
78
|
return this._tokenCache.get(hash);
|
|
@@ -80,7 +81,7 @@ class RpcBDSEthereum {
|
|
|
80
81
|
const contract = new ethers_1.ethers.Contract(hash, ERC20_1.ERC20_ABI, provider);
|
|
81
82
|
const decimals = yield contract.decimals();
|
|
82
83
|
const symbol = yield contract.symbol();
|
|
83
|
-
const token =
|
|
84
|
+
const token = this._tokenService.normalizeToken({
|
|
84
85
|
decimals,
|
|
85
86
|
symbol,
|
|
86
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 &&
|
|
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 (
|
|
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
|
|
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/${
|
|
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/${
|
|
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/${
|
|
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/{
|
|
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({
|
|
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({
|
|
61
|
+
getNft({ collectionHash, tokenHash }) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
const url = this.getUrlWithParams({
|
|
64
|
-
contract:
|
|
65
|
-
tokenIds: [
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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({
|
|
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({
|
|
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(
|
|
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: ${
|
|
44
|
+
throw new Error(`Token not found: ${collectionHash}`);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TokenServiceEthereum = void 0;
|
|
4
4
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
5
5
|
const ethers_1 = require("ethers");
|
|
6
|
-
class
|
|
7
|
-
|
|
8
|
-
let fixedHash =
|
|
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.
|
|
18
|
+
exports.TokenServiceEthereum = TokenServiceEthereum;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "2.
|
|
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.
|
|
25
|
+
"@cityofzion/blockchain-service": "1.21.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|