@cityofzion/bs-ethereum 2.10.0 → 2.12.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.
- package/dist/BSEthereum.d.ts +7 -5
- package/dist/BSEthereum.js +20 -27
- package/dist/assets/abis/{ERC271.d.ts → ERC721.d.ts} +1 -1
- package/dist/assets/abis/{ERC271.js → ERC721.js} +2 -2
- package/dist/constants/BSEthereumConstants.d.ts +5 -7
- package/dist/constants/BSEthereumConstants.js +21 -38
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/services/blockchain-data/DoraBDSEthereum.d.ts +11 -0
- package/dist/services/blockchain-data/DoraBDSEthereum.js +154 -0
- package/dist/services/blockchain-data/MoralisBDSEthereum.d.ts +6 -4
- package/dist/services/blockchain-data/MoralisBDSEthereum.js +55 -9
- package/dist/services/blockchain-data/RpcBDSEthereum.d.ts +6 -4
- package/dist/services/blockchain-data/RpcBDSEthereum.js +10 -0
- package/dist/services/explorer/BlockscoutESEthereum.d.ts +5 -5
- package/dist/services/explorer/BlockscoutESEthereum.js +55 -36
- package/dist/services/ledger/EthersLedgerServiceEthereum.js +1 -0
- package/dist/services/nft-data/GhostMarketNDSEthereum.d.ts +3 -5
- package/dist/services/nft-data/GhostMarketNDSEthereum.js +15 -14
- package/package.json +5 -3
- package/dist/services/blockchain-data/BlockscoutBDSEthereum.d.ts +0 -16
- package/dist/services/blockchain-data/BlockscoutBDSEthereum.js +0 -314
- package/dist/services/exchange-data/FlamingoForthewinEDSNeox.d.ts +0 -7
- package/dist/services/exchange-data/FlamingoForthewinEDSNeox.js +0 -67
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BalanceResponse, BlockchainDataService, ContractResponse, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NetworkId, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
3
|
-
export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
4
|
-
_network: Network<
|
|
3
|
+
export declare class RpcBDSEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> implements BlockchainDataService {
|
|
4
|
+
_network: Network<BSNetworkId>;
|
|
5
5
|
_tokenCache: Map<string, Token>;
|
|
6
6
|
maxTimeToConfirmTransactionInMs: number;
|
|
7
|
-
constructor(network: Network<
|
|
7
|
+
constructor(network: Network<BSNetworkId>);
|
|
8
8
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
9
9
|
getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
10
|
+
getFullTransactionsByAddress(_params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
11
|
+
exportFullTransactionsByAddress(_params: ExportTransactionsByAddressParams): Promise<string>;
|
|
10
12
|
getContract(_hash: string): Promise<ContractResponse>;
|
|
11
13
|
getTokenInfo(hash: string): Promise<Token>;
|
|
12
14
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
@@ -52,6 +52,16 @@ class RpcBDSEthereum {
|
|
|
52
52
|
throw new Error("RPC doesn't support get transactions history of address");
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
getFullTransactionsByAddress(_params) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
throw new Error('Method not supported.');
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exportFullTransactionsByAddress(_params) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
throw new Error('Method not supported.');
|
|
63
|
+
});
|
|
64
|
+
}
|
|
55
65
|
getContract(_hash) {
|
|
56
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
67
|
throw new Error("RPC doesn't support contract info");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { BuildNftUrlParams, ExplorerService, Network } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BuildNftUrlParams, ExplorerService, Network, NetworkId } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
3
|
-
export declare class BlockscoutESEthereum implements ExplorerService {
|
|
3
|
+
export declare class BlockscoutESEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> implements ExplorerService {
|
|
4
4
|
#private;
|
|
5
|
-
|
|
6
|
-
static isSupported(network: Network<BSEthereumNetworkId>): boolean;
|
|
7
|
-
constructor(network: Network<BSEthereumNetworkId>);
|
|
5
|
+
constructor(network: Network<BSEthereumNetworkId>, baseUrlByNetworkId?: Partial<Record<BSNetworkId, string>>);
|
|
8
6
|
buildTransactionUrl(hash: string): string;
|
|
9
7
|
buildContractUrl(contractHash: string): string;
|
|
10
8
|
buildNftUrl(params: BuildNftUrlParams): string;
|
|
11
9
|
getAddressTemplateUrl(): string | undefined;
|
|
12
10
|
getTxTemplateUrl(): string | undefined;
|
|
11
|
+
getNftTemplateUrl(): string | undefined;
|
|
12
|
+
getContractTemplateUrl(): string | undefined;
|
|
13
13
|
}
|
|
@@ -10,64 +10,83 @@ 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_network;
|
|
13
|
+
var _BlockscoutESEthereum_instances, _BlockscoutESEthereum_network, _BlockscoutESEthereum_baseUrlByNetworkId, _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 DEFAULT_BASE_URL_BY_NETWORK_ID = {
|
|
18
|
+
[BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID]: 'https://eth.blockscout.com',
|
|
19
|
+
'10': 'https://optimism.blockscout.com',
|
|
20
|
+
[BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID]: 'https://polygon.blockscout.com',
|
|
21
|
+
[BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID]: 'https://base.blockscout.com',
|
|
22
|
+
[BSEthereumConstants_1.BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID]: 'https://arbitrum.blockscout.com',
|
|
23
|
+
'42220': 'https://explorer.celo.org/mainnet',
|
|
24
|
+
'59144': 'https://explorer.linea.build',
|
|
25
|
+
'1101': 'https://zkevm.blockscout.com',
|
|
26
|
+
'11155111': 'https://eth-sepolia.blockscout.com',
|
|
27
|
+
};
|
|
17
28
|
class BlockscoutESEthereum {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
constructor(network) {
|
|
29
|
+
constructor(network, baseUrlByNetworkId) {
|
|
30
|
+
_BlockscoutESEthereum_instances.add(this);
|
|
22
31
|
_BlockscoutESEthereum_network.set(this, void 0);
|
|
32
|
+
_BlockscoutESEthereum_baseUrlByNetworkId.set(this, void 0);
|
|
23
33
|
__classPrivateFieldSet(this, _BlockscoutESEthereum_network, network, "f");
|
|
34
|
+
__classPrivateFieldSet(this, _BlockscoutESEthereum_baseUrlByNetworkId, baseUrlByNetworkId !== null && baseUrlByNetworkId !== void 0 ? baseUrlByNetworkId : DEFAULT_BASE_URL_BY_NETWORK_ID, "f");
|
|
24
35
|
}
|
|
25
36
|
buildTransactionUrl(hash) {
|
|
26
|
-
|
|
27
|
-
throw new Error('Network not supported');
|
|
28
|
-
}
|
|
29
|
-
const baseURL = BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID[__classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f").id];
|
|
37
|
+
const baseURL = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
|
|
30
38
|
return `${baseURL}/tx/${hash}`;
|
|
31
39
|
}
|
|
32
40
|
buildContractUrl(contractHash) {
|
|
33
|
-
|
|
34
|
-
throw new Error('Network not supported');
|
|
35
|
-
}
|
|
36
|
-
const baseURL = BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID[__classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f").id];
|
|
41
|
+
const baseURL = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
|
|
37
42
|
return `${baseURL}/address/${contractHash}`;
|
|
38
43
|
}
|
|
39
44
|
buildNftUrl(params) {
|
|
40
|
-
|
|
41
|
-
throw new Error('Network not supported');
|
|
42
|
-
}
|
|
43
|
-
const baseURL = BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID[__classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f").id];
|
|
45
|
+
const baseURL = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
|
|
44
46
|
return `${baseURL}/token/${params.contractHash}/instance/${params.tokenId}`;
|
|
45
47
|
}
|
|
46
48
|
getAddressTemplateUrl() {
|
|
47
|
-
|
|
49
|
+
try {
|
|
50
|
+
const baseUrl = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
|
|
51
|
+
return `${baseUrl}/address/{address}`;
|
|
52
|
+
}
|
|
53
|
+
catch (_a) {
|
|
48
54
|
return undefined;
|
|
49
|
-
|
|
50
|
-
return `${baseUrl}/address/{address}`;
|
|
55
|
+
}
|
|
51
56
|
}
|
|
52
57
|
getTxTemplateUrl() {
|
|
53
|
-
|
|
58
|
+
try {
|
|
59
|
+
const baseUrl = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
|
|
60
|
+
return `${baseUrl}/tx/{txId}`;
|
|
61
|
+
}
|
|
62
|
+
catch (_a) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
getNftTemplateUrl() {
|
|
67
|
+
try {
|
|
68
|
+
const baseUrl = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
|
|
69
|
+
return `${baseUrl}/token/{hash}/instance/{tokenId}`;
|
|
70
|
+
}
|
|
71
|
+
catch (_a) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
getContractTemplateUrl() {
|
|
76
|
+
try {
|
|
77
|
+
const baseUrl = __classPrivateFieldGet(this, _BlockscoutESEthereum_instances, "m", _BlockscoutESEthereum_getBaseUrl).call(this, __classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f"));
|
|
78
|
+
return `${baseUrl}/address/{hash}`;
|
|
79
|
+
}
|
|
80
|
+
catch (_a) {
|
|
54
81
|
return undefined;
|
|
55
|
-
|
|
56
|
-
return `${baseUrl}/tx/{txId}`;
|
|
82
|
+
}
|
|
57
83
|
}
|
|
58
84
|
}
|
|
59
85
|
exports.BlockscoutESEthereum = BlockscoutESEthereum;
|
|
60
|
-
_BlockscoutESEthereum_network = new WeakMap()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'42161': 'https://arbitrum.blockscout.com',
|
|
67
|
-
'42220': 'https://explorer.celo.org/mainnet',
|
|
68
|
-
[BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID]: 'https://xexplorer.neo.org',
|
|
69
|
-
'59144': 'https://explorer.linea.build',
|
|
70
|
-
'1101': 'https://zkevm.blockscout.com',
|
|
71
|
-
'11155111': 'https://eth-sepolia.blockscout.com',
|
|
72
|
-
[BSEthereumConstants_1.BSEthereumConstants.NEOX_TESTNET_NETWORK_ID]: 'https://xt4scan.ngd.network',
|
|
86
|
+
_BlockscoutESEthereum_network = new WeakMap(), _BlockscoutESEthereum_baseUrlByNetworkId = new WeakMap(), _BlockscoutESEthereum_instances = new WeakSet(), _BlockscoutESEthereum_getBaseUrl = function _BlockscoutESEthereum_getBaseUrl(network) {
|
|
87
|
+
const baseUrl = __classPrivateFieldGet(this, _BlockscoutESEthereum_baseUrlByNetworkId, "f")[network.id];
|
|
88
|
+
if (!baseUrl) {
|
|
89
|
+
throw new Error('Network not supported');
|
|
90
|
+
}
|
|
91
|
+
return baseUrl;
|
|
73
92
|
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network, NetworkId } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { RpcNDSEthereum } from './RpcNDSEthereum';
|
|
3
3
|
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
4
|
-
export declare class GhostMarketNDSEthereum extends RpcNDSEthereum {
|
|
4
|
+
export declare class GhostMarketNDSEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> extends RpcNDSEthereum {
|
|
5
5
|
#private;
|
|
6
|
-
|
|
7
|
-
static CONFIG_BY_NETWORK_ID: Partial<Record<BSEthereumNetworkId, string>>;
|
|
8
|
-
constructor(network: Network<BSEthereumNetworkId>);
|
|
6
|
+
constructor(network: Network<BSNetworkId>, ghostMarketChainByNetworkId?: Partial<Record<BSNetworkId, string>>);
|
|
9
7
|
getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
10
8
|
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
11
9
|
private treatGhostMarketImage;
|
|
@@ -22,18 +22,28 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
|
-
var _GhostMarketNDSEthereum_network;
|
|
25
|
+
var _GhostMarketNDSEthereum_network, _GhostMarketNDSEthereum_ghostMarketChainByNetworkId;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.GhostMarketNDSEthereum = void 0;
|
|
28
28
|
const query_string_1 = __importDefault(require("query-string"));
|
|
29
29
|
const axios_1 = __importDefault(require("axios"));
|
|
30
30
|
const RpcNDSEthereum_1 = require("./RpcNDSEthereum");
|
|
31
31
|
const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
|
|
32
|
+
const BASE_URL = 'https://api.ghostmarket.io/api/v2';
|
|
33
|
+
const GHOSTMARKET_CHAIN_BY_NETWORK_ID = {
|
|
34
|
+
[BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID]: 'eth',
|
|
35
|
+
'56': 'bsc',
|
|
36
|
+
[BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID]: 'polygon',
|
|
37
|
+
'43114': 'avalanche',
|
|
38
|
+
[BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID]: 'base',
|
|
39
|
+
};
|
|
32
40
|
class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
33
|
-
constructor(network) {
|
|
41
|
+
constructor(network, ghostMarketChainByNetworkId) {
|
|
34
42
|
super(network);
|
|
35
43
|
_GhostMarketNDSEthereum_network.set(this, void 0);
|
|
44
|
+
_GhostMarketNDSEthereum_ghostMarketChainByNetworkId.set(this, void 0);
|
|
36
45
|
__classPrivateFieldSet(this, _GhostMarketNDSEthereum_network, network, "f");
|
|
46
|
+
__classPrivateFieldSet(this, _GhostMarketNDSEthereum_ghostMarketChainByNetworkId, ghostMarketChainByNetworkId !== null && ghostMarketChainByNetworkId !== void 0 ? ghostMarketChainByNetworkId : GHOSTMARKET_CHAIN_BY_NETWORK_ID, "f");
|
|
37
47
|
}
|
|
38
48
|
getNftsByAddress({ address, size = 18, cursor }) {
|
|
39
49
|
var _a;
|
|
@@ -70,11 +80,11 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
|
70
80
|
return srcImage;
|
|
71
81
|
}
|
|
72
82
|
getUrlWithParams(params) {
|
|
73
|
-
const chain =
|
|
83
|
+
const chain = __classPrivateFieldGet(this, _GhostMarketNDSEthereum_ghostMarketChainByNetworkId, "f")[__classPrivateFieldGet(this, _GhostMarketNDSEthereum_network, "f").id];
|
|
74
84
|
if (!chain)
|
|
75
85
|
throw new Error('Unsupported network');
|
|
76
86
|
const parameters = query_string_1.default.stringify(Object.assign({ chain, ownersChains: [chain] }, params), { arrayFormat: 'bracket' });
|
|
77
|
-
return `${
|
|
87
|
+
return `${BASE_URL}/assets?${parameters}`;
|
|
78
88
|
}
|
|
79
89
|
parse(data) {
|
|
80
90
|
var _a, _b;
|
|
@@ -96,13 +106,4 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
108
|
exports.GhostMarketNDSEthereum = GhostMarketNDSEthereum;
|
|
99
|
-
_GhostMarketNDSEthereum_network = new WeakMap();
|
|
100
|
-
GhostMarketNDSEthereum.BASE_URL = 'https://api.ghostmarket.io/api/v2';
|
|
101
|
-
GhostMarketNDSEthereum.CONFIG_BY_NETWORK_ID = {
|
|
102
|
-
'1': 'eth',
|
|
103
|
-
'56': 'bsc',
|
|
104
|
-
'137': 'polygon',
|
|
105
|
-
'43114': 'avalanche',
|
|
106
|
-
'8453': 'base',
|
|
107
|
-
[BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID]: 'neox',
|
|
108
|
-
};
|
|
109
|
+
_GhostMarketNDSEthereum_network = new WeakMap(), _GhostMarketNDSEthereum_ghostMarketChainByNetworkId = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"/dist"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"axios": "1.
|
|
13
|
+
"axios": "1.8.2",
|
|
14
14
|
"ethers": "5.7.2",
|
|
15
15
|
"query-string": "7.1.3",
|
|
16
16
|
"@ethersproject/json-wallets": "5.7.0",
|
|
@@ -20,7 +20,9 @@
|
|
|
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/
|
|
23
|
+
"@cityofzion/dora-ts": "0.5.0",
|
|
24
|
+
"date-fns": "~4.1.0",
|
|
25
|
+
"@cityofzion/blockchain-service": "1.18.0"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
3
|
-
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
4
|
-
export declare class BlockscoutBDSEthereum extends RpcBDSEthereum {
|
|
5
|
-
static BASE_URL_BY_CHAIN_ID: Partial<Record<BSEthereumNetworkId, string>>;
|
|
6
|
-
static isNeoX(network: Network<BSEthereumNetworkId>): boolean;
|
|
7
|
-
static getClient(network: Network<BSEthereumNetworkId>): import("axios").AxiosInstance;
|
|
8
|
-
constructor(network: Network<BSEthereumNetworkId>);
|
|
9
|
-
maxTimeToConfirmTransactionInMs: number;
|
|
10
|
-
getTransaction(txid: string): Promise<TransactionResponse>;
|
|
11
|
-
getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
12
|
-
getContract(contractHash: string): Promise<ContractResponse>;
|
|
13
|
-
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
14
|
-
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
15
|
-
getBlockHeight(): Promise<number>;
|
|
16
|
-
}
|
|
@@ -1,314 +0,0 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.BlockscoutBDSEthereum = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
18
|
-
const ethers_1 = require("ethers");
|
|
19
|
-
const ERC20_1 = require("../../assets/abis/ERC20");
|
|
20
|
-
const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
|
|
21
|
-
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
22
|
-
class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
23
|
-
static isNeoX(network) {
|
|
24
|
-
return BSEthereumConstants_1.BSEthereumConstants.NEOX_NETWORK_IDS.includes(network.id);
|
|
25
|
-
}
|
|
26
|
-
static getClient(network) {
|
|
27
|
-
const baseURL = BlockscoutBDSEthereum.BASE_URL_BY_CHAIN_ID[network.id];
|
|
28
|
-
if (!baseURL) {
|
|
29
|
-
throw new Error('Unsupported network');
|
|
30
|
-
}
|
|
31
|
-
return axios_1.default.create({
|
|
32
|
-
baseURL,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
constructor(network) {
|
|
36
|
-
super(network);
|
|
37
|
-
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5;
|
|
38
|
-
}
|
|
39
|
-
getTransaction(txid) {
|
|
40
|
-
const _super = Object.create(null, {
|
|
41
|
-
getTransaction: { get: () => super.getTransaction }
|
|
42
|
-
});
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
45
|
-
return _super.getTransaction.call(this, txid);
|
|
46
|
-
}
|
|
47
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
48
|
-
const { data } = yield client.get(`/transactions/${txid}`);
|
|
49
|
-
if (!data || 'message' in data) {
|
|
50
|
-
throw new Error('Transaction not found');
|
|
51
|
-
}
|
|
52
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
53
|
-
const transfers = [];
|
|
54
|
-
const hasNativeTokenBeingTransferred = data.value !== '0';
|
|
55
|
-
if (hasNativeTokenBeingTransferred) {
|
|
56
|
-
transfers.push({
|
|
57
|
-
amount: ethers_1.ethers.utils.formatUnits(data.value, nativeToken.decimals),
|
|
58
|
-
from: data.from.hash,
|
|
59
|
-
to: data.to.hash,
|
|
60
|
-
type: 'token',
|
|
61
|
-
contractHash: nativeToken.hash,
|
|
62
|
-
token: nativeToken,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const hasTokenTransfers = data.token_transfers && data.token_transfers.length > 0;
|
|
66
|
-
if (hasTokenTransfers) {
|
|
67
|
-
for (const tokenTransfer of data.token_transfers) {
|
|
68
|
-
if (tokenTransfer.token.type === 'ERC-20') {
|
|
69
|
-
transfers.push({
|
|
70
|
-
amount: ethers_1.ethers.utils.formatUnits(tokenTransfer.total.value, tokenTransfer.total.decimals),
|
|
71
|
-
from: tokenTransfer.from.hash,
|
|
72
|
-
to: tokenTransfer.to.hash,
|
|
73
|
-
type: 'token',
|
|
74
|
-
contractHash: tokenTransfer.token.address,
|
|
75
|
-
token: {
|
|
76
|
-
symbol: tokenTransfer.token.symbol,
|
|
77
|
-
name: tokenTransfer.token.name,
|
|
78
|
-
hash: tokenTransfer.token.address,
|
|
79
|
-
decimals: Number(tokenTransfer.total.decimals),
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (tokenTransfer.token.type === 'ERC-721') {
|
|
85
|
-
transfers.push({
|
|
86
|
-
tokenId: tokenTransfer.total.token_id,
|
|
87
|
-
from: tokenTransfer.from.hash,
|
|
88
|
-
to: tokenTransfer.to.hash,
|
|
89
|
-
type: 'nft',
|
|
90
|
-
contractHash: tokenTransfer.token.address,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
block: data.block,
|
|
97
|
-
hash: data.hash,
|
|
98
|
-
fee: ethers_1.ethers.utils.formatUnits(data.fee.value, nativeToken.decimals),
|
|
99
|
-
time: new Date(data.timestamp).getTime() / 1000,
|
|
100
|
-
notifications: [],
|
|
101
|
-
transfers,
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
getTransactionsByAddress(params) {
|
|
106
|
-
const _super = Object.create(null, {
|
|
107
|
-
getTransactionsByAddress: { get: () => super.getTransactionsByAddress }
|
|
108
|
-
});
|
|
109
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
111
|
-
return _super.getTransactionsByAddress.call(this, params);
|
|
112
|
-
}
|
|
113
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
114
|
-
const { data } = yield client.get(`/addresses/${params.address}/transactions`, {
|
|
115
|
-
params: {
|
|
116
|
-
next_page_params: params.nextPageParams,
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
if (!data || 'message' in data) {
|
|
120
|
-
throw new Error('Transactions not found');
|
|
121
|
-
}
|
|
122
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
123
|
-
const transactions = [];
|
|
124
|
-
const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
const transfers = [];
|
|
126
|
-
const hasNativeTokenBeingTransferred = item.value !== '0';
|
|
127
|
-
if (hasNativeTokenBeingTransferred) {
|
|
128
|
-
transfers.push({
|
|
129
|
-
amount: ethers_1.ethers.utils.formatUnits(item.value, nativeToken.decimals),
|
|
130
|
-
from: item.from.hash,
|
|
131
|
-
to: item.to.hash,
|
|
132
|
-
type: 'token',
|
|
133
|
-
contractHash: nativeToken.hash,
|
|
134
|
-
token: nativeToken,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
if (item.raw_input) {
|
|
138
|
-
try {
|
|
139
|
-
const ERC20Interface = new ethers_1.ethers.utils.Interface(ERC20_1.ERC20_ABI);
|
|
140
|
-
const result = ERC20Interface.decodeFunctionData('transfer', item.raw_input);
|
|
141
|
-
if (!result)
|
|
142
|
-
throw new Error('Invalid ERC20 transfer');
|
|
143
|
-
const contractHash = item.to.hash;
|
|
144
|
-
const token = yield this.getTokenInfo(contractHash);
|
|
145
|
-
const to = result[0];
|
|
146
|
-
const value = result[1];
|
|
147
|
-
transfers.push({
|
|
148
|
-
amount: ethers_1.ethers.utils.formatUnits(value, token.decimals),
|
|
149
|
-
from: item.from.hash,
|
|
150
|
-
to,
|
|
151
|
-
type: 'token',
|
|
152
|
-
contractHash: item.to.hash,
|
|
153
|
-
token,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
/* empty */
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
transactions.push({
|
|
161
|
-
block: item.block,
|
|
162
|
-
hash: item.hash,
|
|
163
|
-
fee: ethers_1.ethers.utils.formatUnits(item.fee.value, nativeToken.decimals),
|
|
164
|
-
time: new Date(item.timestamp).getTime() / 1000,
|
|
165
|
-
notifications: [],
|
|
166
|
-
transfers,
|
|
167
|
-
});
|
|
168
|
-
}));
|
|
169
|
-
yield Promise.allSettled(promises);
|
|
170
|
-
return {
|
|
171
|
-
transactions,
|
|
172
|
-
nextPageParams: data.next_page_params,
|
|
173
|
-
};
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
getContract(contractHash) {
|
|
177
|
-
const _super = Object.create(null, {
|
|
178
|
-
getContract: { get: () => super.getContract }
|
|
179
|
-
});
|
|
180
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
182
|
-
return _super.getContract.call(this, contractHash);
|
|
183
|
-
}
|
|
184
|
-
try {
|
|
185
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
186
|
-
const { data } = yield client.get(`/smart-contracts/${contractHash}`);
|
|
187
|
-
if (!data || 'message' in data) {
|
|
188
|
-
throw new Error('Contract not found');
|
|
189
|
-
}
|
|
190
|
-
const methods = [];
|
|
191
|
-
data.abi.forEach(abi => {
|
|
192
|
-
var _a, _b;
|
|
193
|
-
if (abi.type !== 'function')
|
|
194
|
-
return;
|
|
195
|
-
const parameters = (_a = abi.inputs) === null || _a === void 0 ? void 0 : _a.map(param => ({
|
|
196
|
-
name: param.name,
|
|
197
|
-
type: param.type,
|
|
198
|
-
}));
|
|
199
|
-
methods.push({
|
|
200
|
-
name: (_b = abi.name) !== null && _b !== void 0 ? _b : '',
|
|
201
|
-
parameters: parameters !== null && parameters !== void 0 ? parameters : [],
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
return {
|
|
205
|
-
hash: contractHash,
|
|
206
|
-
name: data.name,
|
|
207
|
-
methods,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
catch (error) {
|
|
211
|
-
throw new Error('Contract not found or not supported');
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
getTokenInfo(tokenHash) {
|
|
216
|
-
const _super = Object.create(null, {
|
|
217
|
-
getTokenInfo: { get: () => super.getTokenInfo }
|
|
218
|
-
});
|
|
219
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
221
|
-
return _super.getTokenInfo.call(this, tokenHash);
|
|
222
|
-
}
|
|
223
|
-
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
224
|
-
if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(nativeAsset.hash) === BSEthereumHelper_1.BSEthereumHelper.normalizeHash(tokenHash)) {
|
|
225
|
-
return nativeAsset;
|
|
226
|
-
}
|
|
227
|
-
if (this._tokenCache.has(tokenHash)) {
|
|
228
|
-
return this._tokenCache.get(tokenHash);
|
|
229
|
-
}
|
|
230
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
231
|
-
const { data } = yield client.get(`/tokens/${tokenHash}`);
|
|
232
|
-
if (!data || 'message' in data) {
|
|
233
|
-
throw new Error('Token not found');
|
|
234
|
-
}
|
|
235
|
-
if (data.type !== 'ERC-20') {
|
|
236
|
-
throw new Error('Token is not an ERC-20 token');
|
|
237
|
-
}
|
|
238
|
-
return {
|
|
239
|
-
decimals: data.decimals ? parseInt(data.decimals) : BSEthereumConstants_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
240
|
-
hash: tokenHash,
|
|
241
|
-
name: data.name,
|
|
242
|
-
symbol: data.symbol,
|
|
243
|
-
};
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
getBalance(address) {
|
|
247
|
-
const _super = Object.create(null, {
|
|
248
|
-
getBalance: { get: () => super.getBalance }
|
|
249
|
-
});
|
|
250
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
252
|
-
return _super.getBalance.call(this, address);
|
|
253
|
-
}
|
|
254
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
255
|
-
const { data: nativeBalance } = yield client.get(`/addresses/${address}`);
|
|
256
|
-
if (!nativeBalance || 'message' in nativeBalance) {
|
|
257
|
-
throw new Error('Native balance not found');
|
|
258
|
-
}
|
|
259
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
260
|
-
const balances = [
|
|
261
|
-
{
|
|
262
|
-
amount: ethers_1.ethers.utils.formatUnits(nativeBalance.coin_balance, nativeToken.decimals),
|
|
263
|
-
token: nativeToken,
|
|
264
|
-
},
|
|
265
|
-
];
|
|
266
|
-
const { data: erc20Balances } = yield client.get(`/addresses/${address}/token-balances`);
|
|
267
|
-
if (!erc20Balances || 'message' in erc20Balances) {
|
|
268
|
-
throw new Error('ERC20 balance not found');
|
|
269
|
-
}
|
|
270
|
-
erc20Balances.forEach(balance => {
|
|
271
|
-
try {
|
|
272
|
-
if (balance.token.type !== 'ERC-20') {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
const token = {
|
|
276
|
-
decimals: balance.token.decimals ? parseInt(balance.token.decimals) : BSEthereumConstants_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
277
|
-
hash: balance.token.address,
|
|
278
|
-
name: balance.token.symbol,
|
|
279
|
-
symbol: balance.token.symbol,
|
|
280
|
-
};
|
|
281
|
-
balances.push({
|
|
282
|
-
amount: ethers_1.ethers.utils.formatUnits(balance.value, token.decimals),
|
|
283
|
-
token,
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
catch (_a) {
|
|
287
|
-
/* empty */
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
return balances;
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
getBlockHeight() {
|
|
294
|
-
const _super = Object.create(null, {
|
|
295
|
-
getBlockHeight: { get: () => super.getBlockHeight }
|
|
296
|
-
});
|
|
297
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
298
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
299
|
-
return _super.getBlockHeight.call(this);
|
|
300
|
-
}
|
|
301
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
302
|
-
const { data } = yield client.get('/blocks');
|
|
303
|
-
if (!data || 'message' in data) {
|
|
304
|
-
throw new Error('Block not found');
|
|
305
|
-
}
|
|
306
|
-
return data.items[0].height;
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
exports.BlockscoutBDSEthereum = BlockscoutBDSEthereum;
|
|
311
|
-
BlockscoutBDSEthereum.BASE_URL_BY_CHAIN_ID = {
|
|
312
|
-
[BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID]: 'https://dora.coz.io/api/neox/mainnet',
|
|
313
|
-
[BSEthereumConstants_1.BSEthereumConstants.NEOX_TESTNET_NETWORK_ID]: 'https://dora-stage.coz.io/api/neox/testnet',
|
|
314
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ExchangeDataService, FlamingoForthewinEDS, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class FlamingoForthewinEDSNeox extends FlamingoForthewinEDS implements ExchangeDataService {
|
|
3
|
-
#private;
|
|
4
|
-
constructor(network: Network);
|
|
5
|
-
getTokenPrices({ tokens }: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
|
|
6
|
-
getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<import("@cityofzion/blockchain-service").TokenPricesHistoryResponse[]>;
|
|
7
|
-
}
|