@cityofzion/bs-ethereum 2.9.9 → 2.11.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.js +7 -7
- package/dist/constants/BSEthereumConstants.d.ts +5 -1
- package/dist/constants/BSEthereumConstants.js +21 -17
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/services/blockchain-data/BlockscoutBDSEthereum.d.ts +6 -5
- package/dist/services/blockchain-data/BlockscoutBDSEthereum.js +29 -14
- package/dist/services/blockchain-data/DoraBDSEthereum.d.ts +10 -0
- package/dist/services/blockchain-data/DoraBDSEthereum.js +148 -0
- package/dist/services/blockchain-data/MoralisBDSEthereum.d.ts +5 -4
- package/dist/services/blockchain-data/MoralisBDSEthereum.js +30 -9
- package/dist/services/blockchain-data/RpcBDSEthereum.d.ts +2 -1
- package/dist/services/blockchain-data/RpcBDSEthereum.js +5 -0
- package/dist/services/exchange-data/FlamingoForthewinEDSNeox.d.ts +7 -0
- package/dist/services/exchange-data/FlamingoForthewinEDSNeox.js +67 -0
- package/dist/services/explorer/BlockscoutESEthereum.d.ts +2 -0
- package/dist/services/explorer/BlockscoutESEthereum.js +19 -6
- package/dist/services/nft-data/GhostMarketNDSEthereum.js +3 -3
- package/package.json +5 -3
- package/dist/services/exchange-data/BlockscoutEDSEthereum.d.ts +0 -7
- package/dist/services/exchange-data/BlockscoutEDSEthereum.js +0 -78
package/dist/BSEthereum.js
CHANGED
|
@@ -47,7 +47,7 @@ const BSEthereumConstants_1 = require("./constants/BSEthereumConstants");
|
|
|
47
47
|
const EthersLedgerServiceEthereum_1 = require("./services/ledger/EthersLedgerServiceEthereum");
|
|
48
48
|
const BSEthereumHelper_1 = require("./helpers/BSEthereumHelper");
|
|
49
49
|
const BlockscoutBDSEthereum_1 = require("./services/blockchain-data/BlockscoutBDSEthereum");
|
|
50
|
-
const
|
|
50
|
+
const FlamingoForthewinEDSNeox_1 = require("./services/exchange-data/FlamingoForthewinEDSNeox");
|
|
51
51
|
const MoralisBDSEthereum_1 = require("./services/blockchain-data/MoralisBDSEthereum");
|
|
52
52
|
const MoralisEDSEthereum_1 = require("./services/exchange-data/MoralisEDSEthereum");
|
|
53
53
|
const GhostMarketNDSEthereum_1 = require("./services/nft-data/GhostMarketNDSEthereum");
|
|
@@ -71,16 +71,16 @@ class BSEthereum {
|
|
|
71
71
|
setNetwork(network) {
|
|
72
72
|
__classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_setTokens).call(this, network);
|
|
73
73
|
this.network = network;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network);
|
|
75
|
+
this.explorerService = new BlockscoutESEthereum_1.BlockscoutESEthereum(network);
|
|
76
|
+
if (BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.isNeoX(network)) {
|
|
77
|
+
this.exchangeDataService = new FlamingoForthewinEDSNeox_1.FlamingoForthewinEDSNeox(network);
|
|
78
|
+
this.blockchainDataService = new BlockscoutBDSEthereum_1.BlockscoutBDSEthereum(network, this.nftDataService, this.explorerService);
|
|
77
79
|
}
|
|
78
80
|
else {
|
|
79
81
|
this.exchangeDataService = new MoralisEDSEthereum_1.MoralisEDSEthereum(network, this.blockchainDataService);
|
|
80
|
-
this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(network);
|
|
82
|
+
this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(network, this.nftDataService, this.explorerService);
|
|
81
83
|
}
|
|
82
|
-
this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network);
|
|
83
|
-
this.explorerService = new BlockscoutESEthereum_1.BlockscoutESEthereum(network);
|
|
84
84
|
}
|
|
85
85
|
validateAddress(address) {
|
|
86
86
|
return ethers_1.ethers.utils.isAddress(address);
|
|
@@ -3,12 +3,16 @@ export type BSEthereumNetworkId = NetworkId<'1' | '10' | '25' | '56' | '137' | '
|
|
|
3
3
|
export declare class BSEthereumConstants {
|
|
4
4
|
static DEFAULT_DECIMALS: number;
|
|
5
5
|
static DEFAULT_GAS_LIMIT: number;
|
|
6
|
+
static readonly ETHEREUM_MAINNET_NETWORK_ID: BSEthereumNetworkId;
|
|
7
|
+
static readonly POLYGON_MAINNET_NETWORK_ID: BSEthereumNetworkId;
|
|
8
|
+
static readonly BASE_MAINNET_NETWORK_ID: BSEthereumNetworkId;
|
|
9
|
+
static readonly ARBITRUM_MAINNET_NETWORK_ID: BSEthereumNetworkId;
|
|
6
10
|
static NATIVE_SYMBOL_BY_NETWORK_ID: Record<BSEthereumNetworkId, string>;
|
|
7
11
|
static NATIVE_WRAPPED_HASH_BY_NETWORK_ID: Partial<Record<BSEthereumNetworkId, string>>;
|
|
8
12
|
static RPC_LIST_BY_NETWORK_ID: Record<BSEthereumNetworkId, string[]>;
|
|
9
13
|
static DEFAULT_BIP44_DERIVATION_PATH: string;
|
|
10
|
-
static NEOX_TESTNET_NETWORK_ID: BSEthereumNetworkId;
|
|
11
14
|
static NEOX_MAINNET_NETWORK_ID: BSEthereumNetworkId;
|
|
15
|
+
static NEOX_TESTNET_NETWORK_ID: BSEthereumNetworkId;
|
|
12
16
|
static NEOX_NETWORK_IDS: BSEthereumNetworkId[];
|
|
13
17
|
static NEOX_TESTNET_NETWORK: Network<BSEthereumNetworkId>;
|
|
14
18
|
static NEOX_MAINNET_NETWORK: Network<BSEthereumNetworkId>;
|
|
@@ -8,6 +8,10 @@ exports.BSEthereumConstants = BSEthereumConstants;
|
|
|
8
8
|
_a = BSEthereumConstants;
|
|
9
9
|
BSEthereumConstants.DEFAULT_DECIMALS = 18;
|
|
10
10
|
BSEthereumConstants.DEFAULT_GAS_LIMIT = 0x5208;
|
|
11
|
+
BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID = '1';
|
|
12
|
+
BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID = '137';
|
|
13
|
+
BSEthereumConstants.BASE_MAINNET_NETWORK_ID = '8453';
|
|
14
|
+
BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID = '42161';
|
|
11
15
|
BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID = {
|
|
12
16
|
'1': 'ETH',
|
|
13
17
|
'10': 'ETH',
|
|
@@ -27,14 +31,14 @@ BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID = {
|
|
|
27
31
|
'12227332': 'GAS',
|
|
28
32
|
};
|
|
29
33
|
BSEthereumConstants.NATIVE_WRAPPED_HASH_BY_NETWORK_ID = {
|
|
30
|
-
|
|
34
|
+
[_a.ETHEREUM_MAINNET_NETWORK_ID]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
31
35
|
'10': '0x4200000000000000000000000000000000000006',
|
|
32
36
|
'25': '0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23',
|
|
33
37
|
'56': '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c',
|
|
34
|
-
|
|
38
|
+
[_a.POLYGON_MAINNET_NETWORK_ID]: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
|
|
35
39
|
'250': '0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83',
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
[_a.BASE_MAINNET_NETWORK_ID]: '0x4200000000000000000000000000000000000006',
|
|
41
|
+
[_a.ARBITRUM_MAINNET_NETWORK_ID]: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
|
|
38
42
|
'42220': '0x471EcE3750Da237f93B8E339c536989b8978a438',
|
|
39
43
|
'43114': '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7',
|
|
40
44
|
'59144': '0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f',
|
|
@@ -127,8 +131,8 @@ BSEthereumConstants.RPC_LIST_BY_NETWORK_ID = {
|
|
|
127
131
|
'12227332': ['https://neoxt4seed1.ngd.network'],
|
|
128
132
|
};
|
|
129
133
|
BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
130
|
-
BSEthereumConstants.NEOX_TESTNET_NETWORK_ID = '12227332';
|
|
131
134
|
BSEthereumConstants.NEOX_MAINNET_NETWORK_ID = '47763';
|
|
135
|
+
BSEthereumConstants.NEOX_TESTNET_NETWORK_ID = '12227332';
|
|
132
136
|
BSEthereumConstants.NEOX_NETWORK_IDS = [_a.NEOX_TESTNET_NETWORK_ID, _a.NEOX_MAINNET_NETWORK_ID];
|
|
133
137
|
BSEthereumConstants.NEOX_TESTNET_NETWORK = {
|
|
134
138
|
id: _a.NEOX_TESTNET_NETWORK_ID,
|
|
@@ -142,14 +146,14 @@ BSEthereumConstants.NEOX_MAINNET_NETWORK = {
|
|
|
142
146
|
};
|
|
143
147
|
BSEthereumConstants.NEOX_NETWORKS = [_a.NEOX_TESTNET_NETWORK, _a.NEOX_MAINNET_NETWORK];
|
|
144
148
|
BSEthereumConstants.MAINNET_NETWORK_IDS = [
|
|
145
|
-
|
|
149
|
+
_a.ETHEREUM_MAINNET_NETWORK_ID,
|
|
146
150
|
'10',
|
|
147
151
|
'25',
|
|
148
152
|
'56',
|
|
149
|
-
|
|
153
|
+
_a.POLYGON_MAINNET_NETWORK_ID,
|
|
150
154
|
'250',
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
_a.BASE_MAINNET_NETWORK_ID,
|
|
156
|
+
_a.ARBITRUM_MAINNET_NETWORK_ID,
|
|
153
157
|
'42220',
|
|
154
158
|
'43114',
|
|
155
159
|
'59144',
|
|
@@ -159,9 +163,9 @@ BSEthereumConstants.TESTNET_NETWORK_IDS = ['1101', '80002', '11155111', _a.NEOX_
|
|
|
159
163
|
BSEthereumConstants.ALL_NETWORK_IDS = [..._a.MAINNET_NETWORK_IDS, ..._a.TESTNET_NETWORK_IDS];
|
|
160
164
|
BSEthereumConstants.MAINNET_NETWORKS = [
|
|
161
165
|
{
|
|
162
|
-
id:
|
|
166
|
+
id: _a.ETHEREUM_MAINNET_NETWORK_ID,
|
|
163
167
|
name: 'Ethereum Mainnet',
|
|
164
|
-
url: _a.RPC_LIST_BY_NETWORK_ID[
|
|
168
|
+
url: _a.RPC_LIST_BY_NETWORK_ID[_a.ETHEREUM_MAINNET_NETWORK_ID][0],
|
|
165
169
|
},
|
|
166
170
|
{
|
|
167
171
|
id: '10',
|
|
@@ -179,9 +183,9 @@ BSEthereumConstants.MAINNET_NETWORKS = [
|
|
|
179
183
|
url: _a.RPC_LIST_BY_NETWORK_ID['56'][0],
|
|
180
184
|
},
|
|
181
185
|
{
|
|
182
|
-
id:
|
|
186
|
+
id: _a.POLYGON_MAINNET_NETWORK_ID,
|
|
183
187
|
name: 'Polygon Mainnet',
|
|
184
|
-
url: _a.RPC_LIST_BY_NETWORK_ID[
|
|
188
|
+
url: _a.RPC_LIST_BY_NETWORK_ID[_a.POLYGON_MAINNET_NETWORK_ID][0],
|
|
185
189
|
},
|
|
186
190
|
{
|
|
187
191
|
id: '250',
|
|
@@ -189,14 +193,14 @@ BSEthereumConstants.MAINNET_NETWORKS = [
|
|
|
189
193
|
url: _a.RPC_LIST_BY_NETWORK_ID['250'][0],
|
|
190
194
|
},
|
|
191
195
|
{
|
|
192
|
-
id:
|
|
196
|
+
id: _a.BASE_MAINNET_NETWORK_ID,
|
|
193
197
|
name: 'Base Protocol Mainnet',
|
|
194
|
-
url: _a.RPC_LIST_BY_NETWORK_ID[
|
|
198
|
+
url: _a.RPC_LIST_BY_NETWORK_ID[_a.BASE_MAINNET_NETWORK_ID][0],
|
|
195
199
|
},
|
|
196
200
|
{
|
|
197
|
-
id:
|
|
201
|
+
id: _a.ARBITRUM_MAINNET_NETWORK_ID,
|
|
198
202
|
name: 'Arbitrum Mainnet',
|
|
199
|
-
url: _a.RPC_LIST_BY_NETWORK_ID[
|
|
203
|
+
url: _a.RPC_LIST_BY_NETWORK_ID[_a.ARBITRUM_MAINNET_NETWORK_ID][0],
|
|
200
204
|
},
|
|
201
205
|
{
|
|
202
206
|
id: '42220',
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export * from './helpers/BSEthereumHelper';
|
|
|
3
3
|
export * from './constants/BSEthereumConstants';
|
|
4
4
|
export * from './services/blockchain-data/BlockscoutBDSEthereum';
|
|
5
5
|
export * from './services/blockchain-data/MoralisBDSEthereum';
|
|
6
|
+
export * from './services/blockchain-data/DoraBDSEthereum';
|
|
6
7
|
export * from './services/blockchain-data/RpcBDSEthereum';
|
|
7
|
-
export * from './services/exchange-data/
|
|
8
|
+
export * from './services/exchange-data/FlamingoForthewinEDSNeox';
|
|
8
9
|
export * from './services/exchange-data/MoralisEDSEthereum';
|
|
9
10
|
export * from './services/explorer/BlockscoutESEthereum';
|
|
10
11
|
export * from './services/ledger/EthersLedgerServiceEthereum';
|
package/dist/index.js
CHANGED
|
@@ -19,8 +19,9 @@ __exportStar(require("./helpers/BSEthereumHelper"), exports);
|
|
|
19
19
|
__exportStar(require("./constants/BSEthereumConstants"), exports);
|
|
20
20
|
__exportStar(require("./services/blockchain-data/BlockscoutBDSEthereum"), exports);
|
|
21
21
|
__exportStar(require("./services/blockchain-data/MoralisBDSEthereum"), exports);
|
|
22
|
+
__exportStar(require("./services/blockchain-data/DoraBDSEthereum"), exports);
|
|
22
23
|
__exportStar(require("./services/blockchain-data/RpcBDSEthereum"), exports);
|
|
23
|
-
__exportStar(require("./services/exchange-data/
|
|
24
|
+
__exportStar(require("./services/exchange-data/FlamingoForthewinEDSNeox"), exports);
|
|
24
25
|
__exportStar(require("./services/exchange-data/MoralisEDSEthereum"), exports);
|
|
25
26
|
__exportStar(require("./services/explorer/BlockscoutESEthereum"), exports);
|
|
26
27
|
__exportStar(require("./services/ledger/EthersLedgerServiceEthereum"), exports);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
1
|
+
import { BalanceResponse, ContractResponse, ExplorerService, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NftDataService, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
3
2
|
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
4
|
-
|
|
3
|
+
import { DoraBDSEthereum } from './DoraBDSEthereum';
|
|
4
|
+
export declare class BlockscoutBDSEthereum extends DoraBDSEthereum {
|
|
5
5
|
static BASE_URL_BY_CHAIN_ID: Partial<Record<BSEthereumNetworkId, string>>;
|
|
6
|
-
static
|
|
6
|
+
static isNeoX(network: Network<BSEthereumNetworkId>): boolean;
|
|
7
7
|
static getClient(network: Network<BSEthereumNetworkId>): import("axios").AxiosInstance;
|
|
8
|
-
constructor(network: Network<BSEthereumNetworkId
|
|
8
|
+
constructor(network: Network<BSEthereumNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService);
|
|
9
9
|
maxTimeToConfirmTransactionInMs: number;
|
|
10
10
|
getTransaction(txid: string): Promise<TransactionResponse>;
|
|
11
11
|
getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
12
|
+
getFullTransactionsByAddress(params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
12
13
|
getContract(contractHash: string): Promise<ContractResponse>;
|
|
13
14
|
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
14
15
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
@@ -13,15 +13,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.BlockscoutBDSEthereum = void 0;
|
|
16
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
16
17
|
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
18
18
|
const ethers_1 = require("ethers");
|
|
19
19
|
const ERC20_1 = require("../../assets/abis/ERC20");
|
|
20
20
|
const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
|
|
21
21
|
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const dora_ts_1 = require("@cityofzion/dora-ts");
|
|
23
|
+
const DoraBDSEthereum_1 = require("./DoraBDSEthereum");
|
|
24
|
+
class BlockscoutBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
25
|
+
static isNeoX(network) {
|
|
26
|
+
return BSEthereumConstants_1.BSEthereumConstants.NEOX_NETWORK_IDS.includes(network.id);
|
|
25
27
|
}
|
|
26
28
|
static getClient(network) {
|
|
27
29
|
const baseURL = BlockscoutBDSEthereum.BASE_URL_BY_CHAIN_ID[network.id];
|
|
@@ -32,8 +34,8 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
32
34
|
baseURL,
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
|
-
constructor(network) {
|
|
36
|
-
super(network);
|
|
37
|
+
constructor(network, nftDataService, explorerService) {
|
|
38
|
+
super(network, [BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID, BSEthereumConstants_1.BSEthereumConstants.NEOX_TESTNET_NETWORK_ID], nftDataService, explorerService);
|
|
37
39
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5;
|
|
38
40
|
}
|
|
39
41
|
getTransaction(txid) {
|
|
@@ -41,7 +43,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
41
43
|
getTransaction: { get: () => super.getTransaction }
|
|
42
44
|
});
|
|
43
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
if (!BlockscoutBDSEthereum.
|
|
46
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
45
47
|
return _super.getTransaction.call(this, txid);
|
|
46
48
|
}
|
|
47
49
|
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
@@ -107,7 +109,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
107
109
|
getTransactionsByAddress: { get: () => super.getTransactionsByAddress }
|
|
108
110
|
});
|
|
109
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
if (!BlockscoutBDSEthereum.
|
|
112
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
111
113
|
return _super.getTransactionsByAddress.call(this, params);
|
|
112
114
|
}
|
|
113
115
|
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
@@ -173,12 +175,25 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
173
175
|
};
|
|
174
176
|
});
|
|
175
177
|
}
|
|
178
|
+
getFullTransactionsByAddress(params) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
this.validateFullTransactionsByAddressParams(params);
|
|
181
|
+
const response = yield dora_ts_1.api.NeoXREST.getFullTransactionsByAddress({
|
|
182
|
+
address: params.address,
|
|
183
|
+
timestampFrom: params.dateFrom,
|
|
184
|
+
timestampTo: params.dateTo,
|
|
185
|
+
network: this._network.id === BSEthereumConstants_1.BSEthereumConstants.NEOX_TESTNET_NETWORK_ID ? 'testnet' : 'mainnet',
|
|
186
|
+
cursor: params.nextCursor,
|
|
187
|
+
});
|
|
188
|
+
return yield this.transformFullTransactionsByAddressResponse(response);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
176
191
|
getContract(contractHash) {
|
|
177
192
|
const _super = Object.create(null, {
|
|
178
193
|
getContract: { get: () => super.getContract }
|
|
179
194
|
});
|
|
180
195
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
if (!BlockscoutBDSEthereum.
|
|
196
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
182
197
|
return _super.getContract.call(this, contractHash);
|
|
183
198
|
}
|
|
184
199
|
try {
|
|
@@ -217,7 +232,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
217
232
|
getTokenInfo: { get: () => super.getTokenInfo }
|
|
218
233
|
});
|
|
219
234
|
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
-
if (!BlockscoutBDSEthereum.
|
|
235
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
221
236
|
return _super.getTokenInfo.call(this, tokenHash);
|
|
222
237
|
}
|
|
223
238
|
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
@@ -248,7 +263,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
248
263
|
getBalance: { get: () => super.getBalance }
|
|
249
264
|
});
|
|
250
265
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
if (!BlockscoutBDSEthereum.
|
|
266
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
252
267
|
return _super.getBalance.call(this, address);
|
|
253
268
|
}
|
|
254
269
|
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
@@ -295,7 +310,7 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
295
310
|
getBlockHeight: { get: () => super.getBlockHeight }
|
|
296
311
|
});
|
|
297
312
|
return __awaiter(this, void 0, void 0, function* () {
|
|
298
|
-
if (!BlockscoutBDSEthereum.
|
|
313
|
+
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
299
314
|
return _super.getBlockHeight.call(this);
|
|
300
315
|
}
|
|
301
316
|
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
@@ -309,6 +324,6 @@ class BlockscoutBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
309
324
|
}
|
|
310
325
|
exports.BlockscoutBDSEthereum = BlockscoutBDSEthereum;
|
|
311
326
|
BlockscoutBDSEthereum.BASE_URL_BY_CHAIN_ID = {
|
|
312
|
-
|
|
313
|
-
|
|
327
|
+
[BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID]: `${blockchain_service_1.BSCommonConstants.DORA_URL}/api/neox/mainnet`,
|
|
328
|
+
[BSEthereumConstants_1.BSEthereumConstants.NEOX_TESTNET_NETWORK_ID]: 'https://dora-stage.coz.io/api/neox/testnet',
|
|
314
329
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
2
|
+
import { ExplorerService, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NftDataService } from '@cityofzion/blockchain-service';
|
|
3
|
+
import { GetFullTransactionsByAddressResponse } from '@cityofzion/dora-ts/dist/interfaces/api/common';
|
|
4
|
+
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
5
|
+
export declare class DoraBDSEthereum extends RpcBDSEthereum {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(network: Network<BSEthereumNetworkId>, supportedFullTransactionsByAddressNetworks: BSEthereumNetworkId[], nftDataService: NftDataService, explorerService: ExplorerService);
|
|
8
|
+
protected transformFullTransactionsByAddressResponse({ nextCursor, ...response }: GetFullTransactionsByAddressResponse): Promise<FullTransactionsByAddressResponse>;
|
|
9
|
+
protected validateFullTransactionsByAddressParams(params: FullTransactionsByAddressParams): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
23
|
+
var t = {};
|
|
24
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25
|
+
t[p] = s[p];
|
|
26
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
27
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
29
|
+
t[p[i]] = s[p[i]];
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
};
|
|
33
|
+
var _DoraBDSEthereum_supportedErc721Standards, _DoraBDSEthereum_supportedErc1155Standards, _DoraBDSEthereum_supportedErc20Standards, _DoraBDSEthereum_supportedFullTransactionsByAddressNetworks, _DoraBDSEthereum_nftDataService, _DoraBDSEthereum_explorerService;
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.DoraBDSEthereum = void 0;
|
|
36
|
+
const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
37
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
38
|
+
const ethers_1 = require("ethers");
|
|
39
|
+
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
40
|
+
class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
41
|
+
constructor(network, supportedFullTransactionsByAddressNetworks, nftDataService, explorerService) {
|
|
42
|
+
super(network);
|
|
43
|
+
_DoraBDSEthereum_supportedErc721Standards.set(this, ['erc721', 'erc-721']);
|
|
44
|
+
_DoraBDSEthereum_supportedErc1155Standards.set(this, ['erc1155', 'erc-1155']);
|
|
45
|
+
_DoraBDSEthereum_supportedErc20Standards.set(this, ['erc20', 'erc-20']);
|
|
46
|
+
_DoraBDSEthereum_supportedFullTransactionsByAddressNetworks.set(this, void 0);
|
|
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((item) => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const txId = item.transactionID;
|
|
66
|
+
const newItem = {
|
|
67
|
+
txId,
|
|
68
|
+
txIdUrl: txId ? txTemplateUrl === null || txTemplateUrl === void 0 ? void 0 : txTemplateUrl.replace('{txId}', txId) : undefined,
|
|
69
|
+
block: item.block,
|
|
70
|
+
date: item.date,
|
|
71
|
+
invocationCount: item.invocationCount,
|
|
72
|
+
notificationCount: item.notificationCount,
|
|
73
|
+
networkFeeAmount: (0, blockchain_service_1.formatNumber)(item.networkFeeAmount, nativeToken.decimals),
|
|
74
|
+
systemFeeAmount: (0, blockchain_service_1.formatNumber)(item.systemFeeAmount, nativeToken.decimals),
|
|
75
|
+
events: [],
|
|
76
|
+
};
|
|
77
|
+
const eventPromises = item.events.map((event) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var _c, _d, _e, _f, _g, _h;
|
|
79
|
+
let nftEvent;
|
|
80
|
+
let assetEvent;
|
|
81
|
+
const { methodName, tokenID: tokenId, contractHash: hash } = event;
|
|
82
|
+
const from = (_c = event.from) !== null && _c !== void 0 ? _c : undefined;
|
|
83
|
+
const to = (_d = event.to) !== null && _d !== void 0 ? _d : undefined;
|
|
84
|
+
const standard = (_g = (_f = (_e = event.supportedStandards) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.toLowerCase()) !== null && _g !== void 0 ? _g : '';
|
|
85
|
+
const isErc1155 = __classPrivateFieldGet(this, _DoraBDSEthereum_supportedErc1155Standards, "f").includes(standard);
|
|
86
|
+
const isErc721 = __classPrivateFieldGet(this, _DoraBDSEthereum_supportedErc721Standards, "f").includes(standard);
|
|
87
|
+
const isErc20 = __classPrivateFieldGet(this, _DoraBDSEthereum_supportedErc20Standards, "f").includes(standard);
|
|
88
|
+
const isNft = (isErc1155 || isErc721) && !!tokenId;
|
|
89
|
+
const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
|
|
90
|
+
const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
|
|
91
|
+
const hashUrl = hash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', hash) : undefined;
|
|
92
|
+
if (isNft) {
|
|
93
|
+
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraBDSEthereum_nftDataService, "f").getNft({ contractHash: hash, tokenId }));
|
|
94
|
+
const nftUrl = hash ? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{hash}', hash).replace('{tokenId}', tokenId) : undefined;
|
|
95
|
+
nftEvent = {
|
|
96
|
+
eventType: 'nft',
|
|
97
|
+
amount: '0',
|
|
98
|
+
methodName,
|
|
99
|
+
from,
|
|
100
|
+
fromUrl,
|
|
101
|
+
to,
|
|
102
|
+
toUrl,
|
|
103
|
+
hash,
|
|
104
|
+
hashUrl,
|
|
105
|
+
tokenId,
|
|
106
|
+
tokenType: isErc1155 ? 'erc-1155' : 'erc-721',
|
|
107
|
+
nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
|
|
108
|
+
nftUrl,
|
|
109
|
+
name: nft === null || nft === void 0 ? void 0 : nft.name,
|
|
110
|
+
collectionName: nft === null || nft === void 0 ? void 0 : nft.collectionName,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(hash));
|
|
115
|
+
const amount = (0, blockchain_service_1.formatNumber)(event.amount, (_h = token === null || token === void 0 ? void 0 : token.decimals) !== null && _h !== void 0 ? _h : event.tokenDecimals);
|
|
116
|
+
assetEvent = {
|
|
117
|
+
eventType: 'token',
|
|
118
|
+
amount,
|
|
119
|
+
methodName,
|
|
120
|
+
from,
|
|
121
|
+
fromUrl,
|
|
122
|
+
to,
|
|
123
|
+
toUrl,
|
|
124
|
+
hash,
|
|
125
|
+
hashUrl,
|
|
126
|
+
token: token !== null && token !== void 0 ? token : undefined,
|
|
127
|
+
tokenType: isErc20 ? 'erc-20' : 'generic',
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
newItem.events.push(isNft ? nftEvent : assetEvent);
|
|
131
|
+
}));
|
|
132
|
+
yield Promise.allSettled(eventPromises);
|
|
133
|
+
data.push(newItem);
|
|
134
|
+
}));
|
|
135
|
+
yield Promise.allSettled(itemPromises);
|
|
136
|
+
return { nextCursor, data };
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
validateFullTransactionsByAddressParams(params) {
|
|
140
|
+
if (!__classPrivateFieldGet(this, _DoraBDSEthereum_supportedFullTransactionsByAddressNetworks, "f").includes(this._network.id))
|
|
141
|
+
throw new Error('This network is not supported');
|
|
142
|
+
blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(params);
|
|
143
|
+
if (!ethers_1.ethers.utils.isAddress(params.address))
|
|
144
|
+
throw new Error('Invalid address param');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.DoraBDSEthereum = DoraBDSEthereum;
|
|
148
|
+
_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,15 +1,16 @@
|
|
|
1
|
-
import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
1
|
+
import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, NftDataService, ExplorerService } from '@cityofzion/blockchain-service';
|
|
3
2
|
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
4
|
-
|
|
3
|
+
import { DoraBDSEthereum } from './DoraBDSEthereum';
|
|
4
|
+
export declare class MoralisBDSEthereum extends DoraBDSEthereum {
|
|
5
5
|
static BASE_URL: string;
|
|
6
6
|
static SUPPORTED_CHAINS: string[];
|
|
7
7
|
static getClient(network: Network<BSEthereumNetworkId>): import("axios").AxiosInstance;
|
|
8
8
|
static isSupported(network: Network<BSEthereumNetworkId>): boolean;
|
|
9
|
-
constructor(network: Network<BSEthereumNetworkId
|
|
9
|
+
constructor(network: Network<BSEthereumNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService);
|
|
10
10
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
11
11
|
getTokenInfo(hash: string): Promise<Token>;
|
|
12
12
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
13
13
|
getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
14
|
+
getFullTransactionsByAddress(params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
14
15
|
getContract(hash: string): Promise<ContractResponse>;
|
|
15
16
|
}
|
|
@@ -13,12 +13,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.MoralisBDSEthereum = void 0;
|
|
16
|
-
const
|
|
16
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
17
17
|
const axios_1 = __importDefault(require("axios"));
|
|
18
18
|
const ethers_1 = require("ethers");
|
|
19
|
+
const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
|
|
19
20
|
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
20
21
|
const ERC20_1 = require("../../assets/abis/ERC20");
|
|
21
|
-
|
|
22
|
+
const dora_ts_1 = require("@cityofzion/dora-ts");
|
|
23
|
+
const DoraBDSEthereum_1 = require("./DoraBDSEthereum");
|
|
24
|
+
class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
22
25
|
static getClient(network) {
|
|
23
26
|
return axios_1.default.create({
|
|
24
27
|
baseURL: MoralisBDSEthereum.BASE_URL,
|
|
@@ -30,8 +33,13 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
30
33
|
static isSupported(network) {
|
|
31
34
|
return MoralisBDSEthereum.SUPPORTED_CHAINS.includes(network.id);
|
|
32
35
|
}
|
|
33
|
-
constructor(network) {
|
|
34
|
-
super(network
|
|
36
|
+
constructor(network, nftDataService, explorerService) {
|
|
37
|
+
super(network, [
|
|
38
|
+
BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID,
|
|
39
|
+
BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID,
|
|
40
|
+
BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID,
|
|
41
|
+
BSEthereumConstants_1.BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID,
|
|
42
|
+
], nftDataService, explorerService);
|
|
35
43
|
}
|
|
36
44
|
getBalance(address) {
|
|
37
45
|
const _super = Object.create(null, {
|
|
@@ -238,6 +246,19 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
238
246
|
};
|
|
239
247
|
});
|
|
240
248
|
}
|
|
249
|
+
getFullTransactionsByAddress(params) {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
+
this.validateFullTransactionsByAddressParams(params);
|
|
252
|
+
const response = yield dora_ts_1.api.EthereumREST.getFullTransactionsByAddress({
|
|
253
|
+
address: params.address,
|
|
254
|
+
timestampFrom: params.dateFrom,
|
|
255
|
+
timestampTo: params.dateTo,
|
|
256
|
+
network: this._network.id,
|
|
257
|
+
cursor: params.nextCursor,
|
|
258
|
+
});
|
|
259
|
+
return yield this.transformFullTransactionsByAddressResponse(response);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
241
262
|
getContract(hash) {
|
|
242
263
|
const _super = Object.create(null, {
|
|
243
264
|
getContract: { get: () => super.getContract }
|
|
@@ -280,18 +301,18 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
280
301
|
}
|
|
281
302
|
}
|
|
282
303
|
exports.MoralisBDSEthereum = MoralisBDSEthereum;
|
|
283
|
-
MoralisBDSEthereum.BASE_URL =
|
|
304
|
+
MoralisBDSEthereum.BASE_URL = `${blockchain_service_1.BSCommonConstants.DORA_URL}/api/v2/meta`;
|
|
284
305
|
MoralisBDSEthereum.SUPPORTED_CHAINS = [
|
|
285
|
-
|
|
306
|
+
BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID,
|
|
286
307
|
'11155111',
|
|
287
308
|
'17000',
|
|
288
|
-
|
|
309
|
+
BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID,
|
|
289
310
|
'80002',
|
|
290
311
|
'56',
|
|
291
312
|
'97',
|
|
292
|
-
|
|
313
|
+
BSEthereumConstants_1.BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID,
|
|
293
314
|
'421614',
|
|
294
|
-
|
|
315
|
+
BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID,
|
|
295
316
|
'84532',
|
|
296
317
|
'10',
|
|
297
318
|
'11155420',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BalanceResponse, BlockchainDataService, ContractResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
3
3
|
export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
4
4
|
_network: Network<BSEthereumNetworkId>;
|
|
@@ -7,6 +7,7 @@ export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
|
7
7
|
constructor(network: Network<BSEthereumNetworkId>);
|
|
8
8
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
9
9
|
getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
10
|
+
getFullTransactionsByAddress(_params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
10
11
|
getContract(_hash: string): Promise<ContractResponse>;
|
|
11
12
|
getTokenInfo(hash: string): Promise<Token>;
|
|
12
13
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
@@ -52,6 +52,11 @@ 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
|
+
}
|
|
55
60
|
getContract(_hash) {
|
|
56
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
62
|
throw new Error("RPC doesn't support contract info");
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _FlamingoForthewinEDSNeox_instances, _FlamingoForthewinEDSNeox_network, _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.FlamingoForthewinEDSNeox = void 0;
|
|
25
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
26
|
+
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
27
|
+
const BlockscoutBDSEthereum_1 = require("../blockchain-data/BlockscoutBDSEthereum");
|
|
28
|
+
class FlamingoForthewinEDSNeox extends blockchain_service_1.FlamingoForthewinEDS {
|
|
29
|
+
constructor(network) {
|
|
30
|
+
super();
|
|
31
|
+
_FlamingoForthewinEDSNeox_instances.add(this);
|
|
32
|
+
_FlamingoForthewinEDSNeox_network.set(this, void 0);
|
|
33
|
+
__classPrivateFieldSet(this, _FlamingoForthewinEDSNeox_network, network, "f");
|
|
34
|
+
}
|
|
35
|
+
getTokenPrices({ tokens }) {
|
|
36
|
+
const _super = Object.create(null, {
|
|
37
|
+
getTokenPrices: { get: () => super.getTokenPrices }
|
|
38
|
+
});
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
__classPrivateFieldGet(this, _FlamingoForthewinEDSNeox_instances, "m", _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork).call(this);
|
|
41
|
+
const gasToken = tokens.find(({ symbol }) => symbol === 'GAS');
|
|
42
|
+
const neoToken = tokens.find(({ symbol }) => symbol === 'NEO');
|
|
43
|
+
if (!gasToken && !neoToken)
|
|
44
|
+
return [];
|
|
45
|
+
return yield _super.getTokenPrices.call(this, {
|
|
46
|
+
tokens: tokens.filter(({ symbol }) => symbol === 'GAS' || symbol === 'NEO'),
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getTokenPriceHistory(params) {
|
|
51
|
+
const _super = Object.create(null, {
|
|
52
|
+
getTokenPriceHistory: { get: () => super.getTokenPriceHistory }
|
|
53
|
+
});
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
__classPrivateFieldGet(this, _FlamingoForthewinEDSNeox_instances, "m", _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork).call(this);
|
|
56
|
+
const { symbol } = params.token;
|
|
57
|
+
if (symbol !== 'GAS' && symbol !== 'NEO')
|
|
58
|
+
throw new Error('Invalid token, it should be GAS or NEO');
|
|
59
|
+
return yield _super.getTokenPriceHistory.call(this, params);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.FlamingoForthewinEDSNeox = FlamingoForthewinEDSNeox;
|
|
64
|
+
_FlamingoForthewinEDSNeox_network = new WeakMap(), _FlamingoForthewinEDSNeox_instances = new WeakSet(), _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork = function _FlamingoForthewinEDSNeox_validateNeoXMainnetNetwork() {
|
|
65
|
+
if (!BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.isNeoX(__classPrivateFieldGet(this, _FlamingoForthewinEDSNeox_network, "f")) || !BSEthereumHelper_1.BSEthereumHelper.isMainnet(__classPrivateFieldGet(this, _FlamingoForthewinEDSNeox_network, "f")))
|
|
66
|
+
throw new Error('Exchange is only available on Neo X Mainnet');
|
|
67
|
+
};
|
|
@@ -10,4 +10,6 @@ export declare class BlockscoutESEthereum implements ExplorerService {
|
|
|
10
10
|
buildNftUrl(params: BuildNftUrlParams): string;
|
|
11
11
|
getAddressTemplateUrl(): string | undefined;
|
|
12
12
|
getTxTemplateUrl(): string | undefined;
|
|
13
|
+
getNftTemplateUrl(): string | undefined;
|
|
14
|
+
getContractTemplateUrl(): string | undefined;
|
|
13
15
|
}
|
|
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _BlockscoutESEthereum_network;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.BlockscoutESEthereum = void 0;
|
|
16
|
+
const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
|
|
16
17
|
class BlockscoutESEthereum {
|
|
17
18
|
static isSupported(network) {
|
|
18
19
|
return !!BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID[network.id];
|
|
@@ -54,19 +55,31 @@ class BlockscoutESEthereum {
|
|
|
54
55
|
const baseUrl = BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID[__classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f").id];
|
|
55
56
|
return `${baseUrl}/tx/{txId}`;
|
|
56
57
|
}
|
|
58
|
+
getNftTemplateUrl() {
|
|
59
|
+
if (!BlockscoutESEthereum.isSupported(__classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f")))
|
|
60
|
+
return undefined;
|
|
61
|
+
const baseUrl = BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID[__classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f").id];
|
|
62
|
+
return `${baseUrl}/token/{hash}/instance/{tokenId}`;
|
|
63
|
+
}
|
|
64
|
+
getContractTemplateUrl() {
|
|
65
|
+
if (!BlockscoutESEthereum.isSupported(__classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f")))
|
|
66
|
+
return undefined;
|
|
67
|
+
const baseUrl = BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID[__classPrivateFieldGet(this, _BlockscoutESEthereum_network, "f").id];
|
|
68
|
+
return `${baseUrl}/address/{hash}`;
|
|
69
|
+
}
|
|
57
70
|
}
|
|
58
71
|
exports.BlockscoutESEthereum = BlockscoutESEthereum;
|
|
59
72
|
_BlockscoutESEthereum_network = new WeakMap();
|
|
60
73
|
BlockscoutESEthereum.BASE_URL_BY_CHAIN_ID = {
|
|
61
|
-
|
|
74
|
+
[BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID]: 'https://eth.blockscout.com',
|
|
62
75
|
'10': 'https://optimism.blockscout.com',
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
[BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID]: 'https://polygon.blockscout.com',
|
|
77
|
+
[BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID]: 'https://base.blockscout.com',
|
|
78
|
+
[BSEthereumConstants_1.BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID]: 'https://arbitrum.blockscout.com',
|
|
66
79
|
'42220': 'https://explorer.celo.org/mainnet',
|
|
67
|
-
|
|
80
|
+
[BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID]: 'https://xexplorer.neo.org',
|
|
68
81
|
'59144': 'https://explorer.linea.build',
|
|
69
82
|
'1101': 'https://zkevm.blockscout.com',
|
|
70
83
|
'11155111': 'https://eth-sepolia.blockscout.com',
|
|
71
|
-
|
|
84
|
+
[BSEthereumConstants_1.BSEthereumConstants.NEOX_TESTNET_NETWORK_ID]: 'https://xt4scan.ngd.network',
|
|
72
85
|
};
|
|
@@ -99,10 +99,10 @@ exports.GhostMarketNDSEthereum = GhostMarketNDSEthereum;
|
|
|
99
99
|
_GhostMarketNDSEthereum_network = new WeakMap();
|
|
100
100
|
GhostMarketNDSEthereum.BASE_URL = 'https://api.ghostmarket.io/api/v2';
|
|
101
101
|
GhostMarketNDSEthereum.CONFIG_BY_NETWORK_ID = {
|
|
102
|
-
|
|
102
|
+
[BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID]: 'eth',
|
|
103
103
|
'56': 'bsc',
|
|
104
|
-
|
|
104
|
+
[BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID]: 'polygon',
|
|
105
105
|
'43114': 'avalanche',
|
|
106
|
-
|
|
106
|
+
[BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID]: 'base',
|
|
107
107
|
[BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID]: 'neox',
|
|
108
108
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.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.4.0",
|
|
24
|
+
"date-fns": "~4.1.0",
|
|
25
|
+
"@cityofzion/blockchain-service": "1.17.1"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CryptoCompareEDS, ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class BlockscoutEDSEthereum extends CryptoCompareEDS implements ExchangeDataService {
|
|
3
|
-
#private;
|
|
4
|
-
constructor(network: Network);
|
|
5
|
-
getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
|
|
6
|
-
getTokenPriceHistory(_params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
|
|
7
|
-
}
|
|
@@ -1,78 +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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
|
-
var _BlockscoutEDSEthereum_network;
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.BlockscoutEDSEthereum = void 0;
|
|
25
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
26
|
-
const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
|
|
27
|
-
const BlockscoutBDSEthereum_1 = require("../blockchain-data/BlockscoutBDSEthereum");
|
|
28
|
-
class BlockscoutEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
|
|
29
|
-
constructor(network) {
|
|
30
|
-
super();
|
|
31
|
-
_BlockscoutEDSEthereum_network.set(this, void 0);
|
|
32
|
-
__classPrivateFieldSet(this, _BlockscoutEDSEthereum_network, network, "f");
|
|
33
|
-
}
|
|
34
|
-
getTokenPrices(params) {
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
if (!BSEthereumHelper_1.BSEthereumHelper.isMainnet(__classPrivateFieldGet(this, _BlockscoutEDSEthereum_network, "f")))
|
|
37
|
-
throw new Error('Exchange is only available on mainnet');
|
|
38
|
-
if (!BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.isSupported(__classPrivateFieldGet(this, _BlockscoutEDSEthereum_network, "f"))) {
|
|
39
|
-
throw new Error('Exchange is not supported on this network');
|
|
40
|
-
}
|
|
41
|
-
const client = BlockscoutBDSEthereum_1.BlockscoutBDSEthereum.getClient(__classPrivateFieldGet(this, _BlockscoutEDSEthereum_network, "f"));
|
|
42
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _BlockscoutEDSEthereum_network, "f"));
|
|
43
|
-
const prices = [];
|
|
44
|
-
const promises = params.tokens.map((token) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
try {
|
|
46
|
-
if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(token.hash) !== BSEthereumHelper_1.BSEthereumHelper.normalizeHash(nativeToken.hash)) {
|
|
47
|
-
const { data } = yield client.get(`/tokens/${token.hash}`);
|
|
48
|
-
const exchangeRateNumber = Number(data.exchange_rate);
|
|
49
|
-
prices.push({
|
|
50
|
-
token,
|
|
51
|
-
usdPrice: isNaN(exchangeRateNumber) ? 0 : exchangeRateNumber,
|
|
52
|
-
});
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const { data } = yield client.get(`/stats`);
|
|
56
|
-
const coinPriceNumber = Number(data.coin_price);
|
|
57
|
-
prices.push({
|
|
58
|
-
token,
|
|
59
|
-
usdPrice: isNaN(coinPriceNumber) ? 0 : coinPriceNumber,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
catch (_a) {
|
|
63
|
-
prices.push({
|
|
64
|
-
token,
|
|
65
|
-
usdPrice: 0,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}));
|
|
69
|
-
yield Promise.allSettled(promises);
|
|
70
|
-
return prices;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
getTokenPriceHistory(_params) {
|
|
74
|
-
throw new Error('Blockscout does not support this feature');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.BlockscoutEDSEthereum = BlockscoutEDSEthereum;
|
|
78
|
-
_BlockscoutEDSEthereum_network = new WeakMap();
|