@cityofzion/bs-ethereum 2.11.0 → 2.12.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 +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 +1 -7
- package/dist/constants/BSEthereumConstants.js +1 -22
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/services/blockchain-data/DoraBDSEthereum.d.ts +6 -5
- package/dist/services/blockchain-data/DoraBDSEthereum.js +8 -2
- package/dist/services/blockchain-data/MoralisBDSEthereum.d.ts +3 -2
- package/dist/services/blockchain-data/MoralisBDSEthereum.js +29 -4
- package/dist/services/blockchain-data/RpcBDSEthereum.d.ts +5 -4
- package/dist/services/blockchain-data/RpcBDSEthereum.js +5 -0
- package/dist/services/explorer/BlockscoutESEthereum.d.ts +3 -5
- package/dist/services/explorer/BlockscoutESEthereum.js +49 -42
- 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 +3 -3
- package/dist/services/blockchain-data/BlockscoutBDSEthereum.d.ts +0 -17
- package/dist/services/blockchain-data/BlockscoutBDSEthereum.js +0 -329
- package/dist/services/exchange-data/FlamingoForthewinEDSNeox.d.ts +0 -7
- package/dist/services/exchange-data/FlamingoForthewinEDSNeox.js +0 -67
package/dist/BSEthereum.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Account, BSCalculableFee, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, ExplorerService, Network, NftDataService, Token, TransferParam, GetLedgerTransport } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
2
3
|
import { BSEthereumNetworkId } from './constants/BSEthereumConstants';
|
|
3
4
|
import { EthersLedgerServiceEthereum } from './services/ledger/EthersLedgerServiceEthereum';
|
|
4
|
-
export declare class BSEthereum<BSName extends string = string> implements BlockchainService<BSName,
|
|
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
6
|
#private;
|
|
6
7
|
readonly name: BSName;
|
|
7
8
|
readonly bip44DerivationPath: string;
|
|
@@ -12,11 +13,12 @@ export declare class BSEthereum<BSName extends string = string> implements Block
|
|
|
12
13
|
ledgerService: EthersLedgerServiceEthereum<BSName>;
|
|
13
14
|
tokens: Token[];
|
|
14
15
|
nftDataService: NftDataService;
|
|
15
|
-
network: Network<
|
|
16
|
+
network: Network<NetworkId>;
|
|
16
17
|
explorerService: ExplorerService;
|
|
17
|
-
constructor(name: BSName, network?: Network<
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
constructor(name: BSName, network?: Network<NetworkId>, getLedgerTransport?: GetLedgerTransport<BSName>);
|
|
19
|
+
generateSigner(account: Account<BSName>): Promise<ethers.Signer>;
|
|
20
|
+
testNetwork(network: Network<NetworkId>): Promise<void>;
|
|
21
|
+
setNetwork(network: Network<NetworkId>): void;
|
|
20
22
|
validateAddress(address: string): boolean;
|
|
21
23
|
validateEncrypted(json: string): boolean;
|
|
22
24
|
validateKey(key: string): boolean;
|
package/dist/BSEthereum.js
CHANGED
|
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
36
|
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");
|
|
37
37
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
38
38
|
};
|
|
39
|
-
var _BSEthereum_instances,
|
|
39
|
+
var _BSEthereum_instances, _BSEthereum_buildTransferParams, _BSEthereum_setTokens;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.BSEthereum = void 0;
|
|
42
42
|
const ethers_1 = require("ethers");
|
|
@@ -46,8 +46,6 @@ const ethersBigNumber = __importStar(require("@ethersproject/bignumber"));
|
|
|
46
46
|
const BSEthereumConstants_1 = require("./constants/BSEthereumConstants");
|
|
47
47
|
const EthersLedgerServiceEthereum_1 = require("./services/ledger/EthersLedgerServiceEthereum");
|
|
48
48
|
const BSEthereumHelper_1 = require("./helpers/BSEthereumHelper");
|
|
49
|
-
const BlockscoutBDSEthereum_1 = require("./services/blockchain-data/BlockscoutBDSEthereum");
|
|
50
|
-
const FlamingoForthewinEDSNeox_1 = require("./services/exchange-data/FlamingoForthewinEDSNeox");
|
|
51
49
|
const MoralisBDSEthereum_1 = require("./services/blockchain-data/MoralisBDSEthereum");
|
|
52
50
|
const MoralisEDSEthereum_1 = require("./services/exchange-data/MoralisEDSEthereum");
|
|
53
51
|
const GhostMarketNDSEthereum_1 = require("./services/nft-data/GhostMarketNDSEthereum");
|
|
@@ -62,6 +60,20 @@ class BSEthereum {
|
|
|
62
60
|
this.bip44DerivationPath = BSEthereumConstants_1.BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH;
|
|
63
61
|
this.setNetwork(network);
|
|
64
62
|
}
|
|
63
|
+
generateSigner(account) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.network.url);
|
|
66
|
+
if (account.isHardware) {
|
|
67
|
+
if (!this.ledgerService.getLedgerTransport)
|
|
68
|
+
throw new Error('You must provide getLedgerTransport function to use Ledger');
|
|
69
|
+
if (typeof account.bip44Path !== 'string')
|
|
70
|
+
throw new Error('Your account must have bip44 path to use Ledger');
|
|
71
|
+
const ledgerTransport = yield this.ledgerService.getLedgerTransport(account);
|
|
72
|
+
return this.ledgerService.getSigner(ledgerTransport, account.bip44Path, provider);
|
|
73
|
+
}
|
|
74
|
+
return new ethers_1.ethers.Wallet(account.key, provider);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
65
77
|
testNetwork(network) {
|
|
66
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
79
|
const blockchainDataServiceClone = new RpcBDSEthereum_1.RpcBDSEthereum(network);
|
|
@@ -73,14 +85,8 @@ class BSEthereum {
|
|
|
73
85
|
this.network = network;
|
|
74
86
|
this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network);
|
|
75
87
|
this.explorerService = new BlockscoutESEthereum_1.BlockscoutESEthereum(network);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.blockchainDataService = new BlockscoutBDSEthereum_1.BlockscoutBDSEthereum(network, this.nftDataService, this.explorerService);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
this.exchangeDataService = new MoralisEDSEthereum_1.MoralisEDSEthereum(network, this.blockchainDataService);
|
|
82
|
-
this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(network, this.nftDataService, this.explorerService);
|
|
83
|
-
}
|
|
88
|
+
this.exchangeDataService = new MoralisEDSEthereum_1.MoralisEDSEthereum(network, this.blockchainDataService);
|
|
89
|
+
this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(network, this.nftDataService, this.explorerService);
|
|
84
90
|
}
|
|
85
91
|
validateAddress(address) {
|
|
86
92
|
return ethers_1.ethers.utils.isAddress(address);
|
|
@@ -150,7 +156,7 @@ class BSEthereum {
|
|
|
150
156
|
}
|
|
151
157
|
transfer(param) {
|
|
152
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
const signer = yield
|
|
159
|
+
const signer = yield this.generateSigner(param.senderAccount);
|
|
154
160
|
const sentTransactionHashes = [];
|
|
155
161
|
let error;
|
|
156
162
|
for (const intent of param.intents) {
|
|
@@ -180,7 +186,7 @@ class BSEthereum {
|
|
|
180
186
|
}
|
|
181
187
|
calculateTransferFee(param) {
|
|
182
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
const signer = yield
|
|
189
|
+
const signer = yield this.generateSigner(param.senderAccount);
|
|
184
190
|
let fee = ethers_1.ethers.utils.parseEther('0');
|
|
185
191
|
for (const intent of param.intents) {
|
|
186
192
|
const { gasPrice, transactionParams } = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_buildTransferParams).call(this, intent);
|
|
@@ -202,20 +208,7 @@ class BSEthereum {
|
|
|
202
208
|
}
|
|
203
209
|
}
|
|
204
210
|
exports.BSEthereum = BSEthereum;
|
|
205
|
-
_BSEthereum_instances = new WeakSet(),
|
|
206
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
-
const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.network.url);
|
|
208
|
-
if (account.isHardware) {
|
|
209
|
-
if (!this.ledgerService.getLedgerTransport)
|
|
210
|
-
throw new Error('You must provide getLedgerTransport function to use Ledger');
|
|
211
|
-
if (typeof account.bip44Path !== 'string')
|
|
212
|
-
throw new Error('Your account must have bip44 path to use Ledger');
|
|
213
|
-
const ledgerTransport = yield this.ledgerService.getLedgerTransport(account);
|
|
214
|
-
return this.ledgerService.getSigner(ledgerTransport, account.bip44Path, provider);
|
|
215
|
-
}
|
|
216
|
-
return new ethers_1.ethers.Wallet(account.key, provider);
|
|
217
|
-
});
|
|
218
|
-
}, _BSEthereum_buildTransferParams = function _BSEthereum_buildTransferParams(intent) {
|
|
211
|
+
_BSEthereum_instances = new WeakSet(), _BSEthereum_buildTransferParams = function _BSEthereum_buildTransferParams(intent) {
|
|
219
212
|
return __awaiter(this, void 0, void 0, function* () {
|
|
220
213
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.network.url);
|
|
221
214
|
let decimals = intent.tokenDecimals;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Network, NetworkId } from '@cityofzion/blockchain-service';
|
|
2
|
-
export type BSEthereumNetworkId = NetworkId<'1' | '10' | '25' | '56' | '137' | '250' | '1101' | '8453' | '80002' | '42161' | '42220' | '43114' | '59144' | '11155111'
|
|
2
|
+
export type BSEthereumNetworkId = NetworkId<'1' | '10' | '25' | '56' | '137' | '250' | '1101' | '8453' | '80002' | '42161' | '42220' | '43114' | '59144' | '11155111'>;
|
|
3
3
|
export declare class BSEthereumConstants {
|
|
4
4
|
static DEFAULT_DECIMALS: number;
|
|
5
5
|
static DEFAULT_GAS_LIMIT: number;
|
|
@@ -11,12 +11,6 @@ export declare class BSEthereumConstants {
|
|
|
11
11
|
static NATIVE_WRAPPED_HASH_BY_NETWORK_ID: Partial<Record<BSEthereumNetworkId, string>>;
|
|
12
12
|
static RPC_LIST_BY_NETWORK_ID: Record<BSEthereumNetworkId, string[]>;
|
|
13
13
|
static DEFAULT_BIP44_DERIVATION_PATH: string;
|
|
14
|
-
static NEOX_MAINNET_NETWORK_ID: BSEthereumNetworkId;
|
|
15
|
-
static NEOX_TESTNET_NETWORK_ID: BSEthereumNetworkId;
|
|
16
|
-
static NEOX_NETWORK_IDS: BSEthereumNetworkId[];
|
|
17
|
-
static NEOX_TESTNET_NETWORK: Network<BSEthereumNetworkId>;
|
|
18
|
-
static NEOX_MAINNET_NETWORK: Network<BSEthereumNetworkId>;
|
|
19
|
-
static NEOX_NETWORKS: Network<BSEthereumNetworkId>[];
|
|
20
14
|
static MAINNET_NETWORK_IDS: BSEthereumNetworkId[];
|
|
21
15
|
static TESTNET_NETWORK_IDS: BSEthereumNetworkId[];
|
|
22
16
|
static ALL_NETWORK_IDS: BSEthereumNetworkId[];
|
|
@@ -27,8 +27,6 @@ BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID = {
|
|
|
27
27
|
'43114': 'AVAX',
|
|
28
28
|
'59144': 'ETH',
|
|
29
29
|
'11155111': 'ETH',
|
|
30
|
-
'47763': 'GAS',
|
|
31
|
-
'12227332': 'GAS',
|
|
32
30
|
};
|
|
33
31
|
BSEthereumConstants.NATIVE_WRAPPED_HASH_BY_NETWORK_ID = {
|
|
34
32
|
[_a.ETHEREUM_MAINNET_NETWORK_ID]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
@@ -127,24 +125,8 @@ BSEthereumConstants.RPC_LIST_BY_NETWORK_ID = {
|
|
|
127
125
|
'https://eth-sepolia-public.unifra.io',
|
|
128
126
|
'https://endpoints.omniatech.io/v1/eth/sepolia/public',
|
|
129
127
|
],
|
|
130
|
-
'47763': ['https://mainnet-1.rpc.banelabs.org'],
|
|
131
|
-
'12227332': ['https://neoxt4seed1.ngd.network'],
|
|
132
128
|
};
|
|
133
129
|
BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
134
|
-
BSEthereumConstants.NEOX_MAINNET_NETWORK_ID = '47763';
|
|
135
|
-
BSEthereumConstants.NEOX_TESTNET_NETWORK_ID = '12227332';
|
|
136
|
-
BSEthereumConstants.NEOX_NETWORK_IDS = [_a.NEOX_TESTNET_NETWORK_ID, _a.NEOX_MAINNET_NETWORK_ID];
|
|
137
|
-
BSEthereumConstants.NEOX_TESTNET_NETWORK = {
|
|
138
|
-
id: _a.NEOX_TESTNET_NETWORK_ID,
|
|
139
|
-
name: 'NeoX Testnet',
|
|
140
|
-
url: _a.RPC_LIST_BY_NETWORK_ID[_a.NEOX_TESTNET_NETWORK_ID][0],
|
|
141
|
-
};
|
|
142
|
-
BSEthereumConstants.NEOX_MAINNET_NETWORK = {
|
|
143
|
-
id: _a.NEOX_MAINNET_NETWORK_ID,
|
|
144
|
-
name: 'NeoX Mainnet',
|
|
145
|
-
url: _a.RPC_LIST_BY_NETWORK_ID[_a.NEOX_MAINNET_NETWORK_ID][0],
|
|
146
|
-
};
|
|
147
|
-
BSEthereumConstants.NEOX_NETWORKS = [_a.NEOX_TESTNET_NETWORK, _a.NEOX_MAINNET_NETWORK];
|
|
148
130
|
BSEthereumConstants.MAINNET_NETWORK_IDS = [
|
|
149
131
|
_a.ETHEREUM_MAINNET_NETWORK_ID,
|
|
150
132
|
'10',
|
|
@@ -157,9 +139,8 @@ BSEthereumConstants.MAINNET_NETWORK_IDS = [
|
|
|
157
139
|
'42220',
|
|
158
140
|
'43114',
|
|
159
141
|
'59144',
|
|
160
|
-
_a.NEOX_MAINNET_NETWORK_ID,
|
|
161
142
|
];
|
|
162
|
-
BSEthereumConstants.TESTNET_NETWORK_IDS = ['1101', '80002', '11155111'
|
|
143
|
+
BSEthereumConstants.TESTNET_NETWORK_IDS = ['1101', '80002', '11155111'];
|
|
163
144
|
BSEthereumConstants.ALL_NETWORK_IDS = [..._a.MAINNET_NETWORK_IDS, ..._a.TESTNET_NETWORK_IDS];
|
|
164
145
|
BSEthereumConstants.MAINNET_NETWORKS = [
|
|
165
146
|
{
|
|
@@ -217,7 +198,6 @@ BSEthereumConstants.MAINNET_NETWORKS = [
|
|
|
217
198
|
name: 'Linea Mainnet',
|
|
218
199
|
url: _a.RPC_LIST_BY_NETWORK_ID['59144'][0],
|
|
219
200
|
},
|
|
220
|
-
_a.NEOX_MAINNET_NETWORK,
|
|
221
201
|
];
|
|
222
202
|
BSEthereumConstants.TESTNET_NETWORKS = [
|
|
223
203
|
{
|
|
@@ -235,7 +215,6 @@ BSEthereumConstants.TESTNET_NETWORKS = [
|
|
|
235
215
|
name: 'Sepolia Testnet',
|
|
236
216
|
url: _a.RPC_LIST_BY_NETWORK_ID['11155111'][0],
|
|
237
217
|
},
|
|
238
|
-
_a.NEOX_TESTNET_NETWORK,
|
|
239
218
|
];
|
|
240
219
|
BSEthereumConstants.ALL_NETWORKS = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
|
|
241
220
|
BSEthereumConstants.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export * from './BSEthereum';
|
|
2
2
|
export * from './helpers/BSEthereumHelper';
|
|
3
3
|
export * from './constants/BSEthereumConstants';
|
|
4
|
-
export * from './services/blockchain-data/BlockscoutBDSEthereum';
|
|
5
4
|
export * from './services/blockchain-data/MoralisBDSEthereum';
|
|
6
5
|
export * from './services/blockchain-data/DoraBDSEthereum';
|
|
7
6
|
export * from './services/blockchain-data/RpcBDSEthereum';
|
|
8
|
-
export * from './services/exchange-data/FlamingoForthewinEDSNeox';
|
|
9
7
|
export * from './services/exchange-data/MoralisEDSEthereum';
|
|
10
8
|
export * from './services/explorer/BlockscoutESEthereum';
|
|
11
9
|
export * from './services/ledger/EthersLedgerServiceEthereum';
|
|
12
10
|
export * from './services/nft-data/GhostMarketNDSEthereum';
|
|
13
11
|
export * from './services/nft-data/RpcNDSEthereum';
|
|
12
|
+
export * from './assets/abis/ERC20';
|
|
13
|
+
export * from './assets/abis/ERC721';
|
package/dist/index.js
CHANGED
|
@@ -17,13 +17,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./BSEthereum"), exports);
|
|
18
18
|
__exportStar(require("./helpers/BSEthereumHelper"), exports);
|
|
19
19
|
__exportStar(require("./constants/BSEthereumConstants"), exports);
|
|
20
|
-
__exportStar(require("./services/blockchain-data/BlockscoutBDSEthereum"), exports);
|
|
21
20
|
__exportStar(require("./services/blockchain-data/MoralisBDSEthereum"), exports);
|
|
22
21
|
__exportStar(require("./services/blockchain-data/DoraBDSEthereum"), exports);
|
|
23
22
|
__exportStar(require("./services/blockchain-data/RpcBDSEthereum"), exports);
|
|
24
|
-
__exportStar(require("./services/exchange-data/FlamingoForthewinEDSNeox"), exports);
|
|
25
23
|
__exportStar(require("./services/exchange-data/MoralisEDSEthereum"), exports);
|
|
26
24
|
__exportStar(require("./services/explorer/BlockscoutESEthereum"), exports);
|
|
27
25
|
__exportStar(require("./services/ledger/EthersLedgerServiceEthereum"), exports);
|
|
28
26
|
__exportStar(require("./services/nft-data/GhostMarketNDSEthereum"), exports);
|
|
29
27
|
__exportStar(require("./services/nft-data/RpcNDSEthereum"), exports);
|
|
28
|
+
__exportStar(require("./assets/abis/ERC20"), exports);
|
|
29
|
+
__exportStar(require("./assets/abis/ERC721"), exports);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
2
|
-
import { ExplorerService, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NftDataService } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { ExplorerService, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NetworkId, NftDataService } from '@cityofzion/blockchain-service';
|
|
3
3
|
import { GetFullTransactionsByAddressResponse } from '@cityofzion/dora-ts/dist/interfaces/api/common';
|
|
4
4
|
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
5
|
-
export declare class DoraBDSEthereum extends RpcBDSEthereum {
|
|
5
|
+
export declare class DoraBDSEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> extends RpcBDSEthereum {
|
|
6
6
|
#private;
|
|
7
|
-
constructor(network: Network<
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
constructor(network: Network<BSNetworkId>, supportedFullTransactionsByAddressNetworks: BSNetworkId[], nftDataService: NftDataService, explorerService: ExplorerService);
|
|
8
|
+
_transformFullTransactionsByAddressResponse({ nextCursor, ...response }: GetFullTransactionsByAddressResponse): Promise<FullTransactionsByAddressResponse>;
|
|
9
|
+
_validateFullTransactionsByAddressParams(params: Pick<FullTransactionsByAddressParams, 'address' | 'dateFrom' | 'dateTo'>): void;
|
|
10
|
+
_validateGetFullTransactionsByAddressParams({ pageSize, ...params }: Pick<FullTransactionsByAddressParams, 'address' | 'dateFrom' | 'dateTo' | 'pageSize'>): void;
|
|
10
11
|
}
|
|
@@ -50,7 +50,7 @@ class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
50
50
|
__classPrivateFieldSet(this, _DoraBDSEthereum_nftDataService, nftDataService, "f");
|
|
51
51
|
__classPrivateFieldSet(this, _DoraBDSEthereum_explorerService, explorerService, "f");
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
_transformFullTransactionsByAddressResponse(_a) {
|
|
54
54
|
var _b;
|
|
55
55
|
var { nextCursor } = _a, response = __rest(_a, ["nextCursor"]);
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -136,13 +136,19 @@ class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
136
136
|
return { nextCursor, data };
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
_validateFullTransactionsByAddressParams(params) {
|
|
140
140
|
if (!__classPrivateFieldGet(this, _DoraBDSEthereum_supportedFullTransactionsByAddressNetworks, "f").includes(this._network.id))
|
|
141
141
|
throw new Error('This network is not supported');
|
|
142
142
|
blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(params);
|
|
143
143
|
if (!ethers_1.ethers.utils.isAddress(params.address))
|
|
144
144
|
throw new Error('Invalid address param');
|
|
145
145
|
}
|
|
146
|
+
_validateGetFullTransactionsByAddressParams(_a) {
|
|
147
|
+
var { pageSize } = _a, params = __rest(_a, ["pageSize"]);
|
|
148
|
+
if (typeof pageSize === 'number' && (isNaN(pageSize) || pageSize < 1 || pageSize > 500))
|
|
149
|
+
throw new Error('Page size should be between 1 and 500');
|
|
150
|
+
this._validateFullTransactionsByAddressParams(params);
|
|
151
|
+
}
|
|
146
152
|
}
|
|
147
153
|
exports.DoraBDSEthereum = DoraBDSEthereum;
|
|
148
154
|
_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,4 +1,4 @@
|
|
|
1
|
-
import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, NftDataService, ExplorerService } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, NftDataService, ExplorerService, ExportTransactionsByAddressParams } 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 {
|
|
@@ -11,6 +11,7 @@ export declare class MoralisBDSEthereum extends DoraBDSEthereum {
|
|
|
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
|
+
getFullTransactionsByAddress({ nextCursor, ...params }: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
15
|
+
exportFullTransactionsByAddress(params: ExportTransactionsByAddressParams): Promise<string>;
|
|
15
16
|
getContract(hash: string): Promise<ContractResponse>;
|
|
16
17
|
}
|
|
@@ -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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
24
|
};
|
|
@@ -246,17 +257,31 @@ class MoralisBDSEthereum extends DoraBDSEthereum_1.DoraBDSEthereum {
|
|
|
246
257
|
};
|
|
247
258
|
});
|
|
248
259
|
}
|
|
249
|
-
getFullTransactionsByAddress(
|
|
260
|
+
getFullTransactionsByAddress(_a) {
|
|
261
|
+
var _b;
|
|
262
|
+
var { nextCursor } = _a, params = __rest(_a, ["nextCursor"]);
|
|
250
263
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
this.
|
|
264
|
+
this._validateGetFullTransactionsByAddressParams(params);
|
|
252
265
|
const response = yield dora_ts_1.api.EthereumREST.getFullTransactionsByAddress({
|
|
253
266
|
address: params.address,
|
|
254
267
|
timestampFrom: params.dateFrom,
|
|
255
268
|
timestampTo: params.dateTo,
|
|
256
269
|
network: this._network.id,
|
|
257
|
-
cursor:
|
|
270
|
+
cursor: nextCursor,
|
|
271
|
+
pageLimit: (_b = params.pageSize) !== null && _b !== void 0 ? _b : 50,
|
|
272
|
+
});
|
|
273
|
+
return yield this._transformFullTransactionsByAddressResponse(response);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
exportFullTransactionsByAddress(params) {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
this._validateFullTransactionsByAddressParams(params);
|
|
279
|
+
return yield dora_ts_1.api.EthereumREST.exportFullTransactionsByAddress({
|
|
280
|
+
address: params.address,
|
|
281
|
+
timestampFrom: params.dateFrom,
|
|
282
|
+
timestampTo: params.dateTo,
|
|
283
|
+
network: this._network.id,
|
|
258
284
|
});
|
|
259
|
-
return yield this.transformFullTransactionsByAddressResponse(response);
|
|
260
285
|
});
|
|
261
286
|
}
|
|
262
287
|
getContract(hash) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { BalanceResponse, BlockchainDataService, ContractResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, 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
10
|
getFullTransactionsByAddress(_params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
11
|
+
exportFullTransactionsByAddress(_params: ExportTransactionsByAddressParams): Promise<string>;
|
|
11
12
|
getContract(_hash: string): Promise<ContractResponse>;
|
|
12
13
|
getTokenInfo(hash: string): Promise<Token>;
|
|
13
14
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
@@ -57,6 +57,11 @@ class RpcBDSEthereum {
|
|
|
57
57
|
throw new Error('Method not supported.');
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
+
exportFullTransactionsByAddress(_params) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
throw new Error('Method not supported.');
|
|
63
|
+
});
|
|
64
|
+
}
|
|
60
65
|
getContract(_hash) {
|
|
61
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
67
|
throw new Error("RPC doesn't support contract info");
|
|
@@ -1,10 +1,8 @@
|
|
|
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;
|
|
@@ -10,76 +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) {
|
|
54
63
|
return undefined;
|
|
55
|
-
|
|
56
|
-
return `${baseUrl}/tx/{txId}`;
|
|
64
|
+
}
|
|
57
65
|
}
|
|
58
66
|
getNftTemplateUrl() {
|
|
59
|
-
|
|
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) {
|
|
60
72
|
return undefined;
|
|
61
|
-
|
|
62
|
-
return `${baseUrl}/token/{hash}/instance/{tokenId}`;
|
|
73
|
+
}
|
|
63
74
|
}
|
|
64
75
|
getContractTemplateUrl() {
|
|
65
|
-
|
|
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) {
|
|
66
81
|
return undefined;
|
|
67
|
-
|
|
68
|
-
return `${baseUrl}/address/{hash}`;
|
|
82
|
+
}
|
|
69
83
|
}
|
|
70
84
|
}
|
|
71
85
|
exports.BlockscoutESEthereum = BlockscoutESEthereum;
|
|
72
|
-
_BlockscoutESEthereum_network = new WeakMap()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
[BSEthereumConstants_1.BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID]: 'https://arbitrum.blockscout.com',
|
|
79
|
-
'42220': 'https://explorer.celo.org/mainnet',
|
|
80
|
-
[BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID]: 'https://xexplorer.neo.org',
|
|
81
|
-
'59144': 'https://explorer.linea.build',
|
|
82
|
-
'1101': 'https://zkevm.blockscout.com',
|
|
83
|
-
'11155111': 'https://eth-sepolia.blockscout.com',
|
|
84
|
-
[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;
|
|
85
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
|
-
[BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID]: 'eth',
|
|
103
|
-
'56': 'bsc',
|
|
104
|
-
[BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID]: 'polygon',
|
|
105
|
-
'43114': 'avalanche',
|
|
106
|
-
[BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID]: '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.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -20,9 +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/dora-ts": "0.
|
|
23
|
+
"@cityofzion/dora-ts": "0.5.1",
|
|
24
24
|
"date-fns": "~4.1.0",
|
|
25
|
-
"@cityofzion/blockchain-service": "1.
|
|
25
|
+
"@cityofzion/blockchain-service": "1.18.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BalanceResponse, ContractResponse, ExplorerService, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NftDataService, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
|
|
3
|
-
import { DoraBDSEthereum } from './DoraBDSEthereum';
|
|
4
|
-
export declare class BlockscoutBDSEthereum extends DoraBDSEthereum {
|
|
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>, nftDataService: NftDataService, explorerService: ExplorerService);
|
|
9
|
-
maxTimeToConfirmTransactionInMs: number;
|
|
10
|
-
getTransaction(txid: string): Promise<TransactionResponse>;
|
|
11
|
-
getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
12
|
-
getFullTransactionsByAddress(params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
13
|
-
getContract(contractHash: string): Promise<ContractResponse>;
|
|
14
|
-
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
15
|
-
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
16
|
-
getBlockHeight(): Promise<number>;
|
|
17
|
-
}
|
|
@@ -1,329 +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 blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
17
|
-
const axios_1 = __importDefault(require("axios"));
|
|
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
|
-
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);
|
|
27
|
-
}
|
|
28
|
-
static getClient(network) {
|
|
29
|
-
const baseURL = BlockscoutBDSEthereum.BASE_URL_BY_CHAIN_ID[network.id];
|
|
30
|
-
if (!baseURL) {
|
|
31
|
-
throw new Error('Unsupported network');
|
|
32
|
-
}
|
|
33
|
-
return axios_1.default.create({
|
|
34
|
-
baseURL,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
constructor(network, nftDataService, explorerService) {
|
|
38
|
-
super(network, [BSEthereumConstants_1.BSEthereumConstants.NEOX_MAINNET_NETWORK_ID, BSEthereumConstants_1.BSEthereumConstants.NEOX_TESTNET_NETWORK_ID], nftDataService, explorerService);
|
|
39
|
-
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5;
|
|
40
|
-
}
|
|
41
|
-
getTransaction(txid) {
|
|
42
|
-
const _super = Object.create(null, {
|
|
43
|
-
getTransaction: { get: () => super.getTransaction }
|
|
44
|
-
});
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
47
|
-
return _super.getTransaction.call(this, txid);
|
|
48
|
-
}
|
|
49
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
50
|
-
const { data } = yield client.get(`/transactions/${txid}`);
|
|
51
|
-
if (!data || 'message' in data) {
|
|
52
|
-
throw new Error('Transaction not found');
|
|
53
|
-
}
|
|
54
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
55
|
-
const transfers = [];
|
|
56
|
-
const hasNativeTokenBeingTransferred = data.value !== '0';
|
|
57
|
-
if (hasNativeTokenBeingTransferred) {
|
|
58
|
-
transfers.push({
|
|
59
|
-
amount: ethers_1.ethers.utils.formatUnits(data.value, nativeToken.decimals),
|
|
60
|
-
from: data.from.hash,
|
|
61
|
-
to: data.to.hash,
|
|
62
|
-
type: 'token',
|
|
63
|
-
contractHash: nativeToken.hash,
|
|
64
|
-
token: nativeToken,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
const hasTokenTransfers = data.token_transfers && data.token_transfers.length > 0;
|
|
68
|
-
if (hasTokenTransfers) {
|
|
69
|
-
for (const tokenTransfer of data.token_transfers) {
|
|
70
|
-
if (tokenTransfer.token.type === 'ERC-20') {
|
|
71
|
-
transfers.push({
|
|
72
|
-
amount: ethers_1.ethers.utils.formatUnits(tokenTransfer.total.value, tokenTransfer.total.decimals),
|
|
73
|
-
from: tokenTransfer.from.hash,
|
|
74
|
-
to: tokenTransfer.to.hash,
|
|
75
|
-
type: 'token',
|
|
76
|
-
contractHash: tokenTransfer.token.address,
|
|
77
|
-
token: {
|
|
78
|
-
symbol: tokenTransfer.token.symbol,
|
|
79
|
-
name: tokenTransfer.token.name,
|
|
80
|
-
hash: tokenTransfer.token.address,
|
|
81
|
-
decimals: Number(tokenTransfer.total.decimals),
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (tokenTransfer.token.type === 'ERC-721') {
|
|
87
|
-
transfers.push({
|
|
88
|
-
tokenId: tokenTransfer.total.token_id,
|
|
89
|
-
from: tokenTransfer.from.hash,
|
|
90
|
-
to: tokenTransfer.to.hash,
|
|
91
|
-
type: 'nft',
|
|
92
|
-
contractHash: tokenTransfer.token.address,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
block: data.block,
|
|
99
|
-
hash: data.hash,
|
|
100
|
-
fee: ethers_1.ethers.utils.formatUnits(data.fee.value, nativeToken.decimals),
|
|
101
|
-
time: new Date(data.timestamp).getTime() / 1000,
|
|
102
|
-
notifications: [],
|
|
103
|
-
transfers,
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
getTransactionsByAddress(params) {
|
|
108
|
-
const _super = Object.create(null, {
|
|
109
|
-
getTransactionsByAddress: { get: () => super.getTransactionsByAddress }
|
|
110
|
-
});
|
|
111
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
113
|
-
return _super.getTransactionsByAddress.call(this, params);
|
|
114
|
-
}
|
|
115
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
116
|
-
const { data } = yield client.get(`/addresses/${params.address}/transactions`, {
|
|
117
|
-
params: {
|
|
118
|
-
next_page_params: params.nextPageParams,
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
if (!data || 'message' in data) {
|
|
122
|
-
throw new Error('Transactions not found');
|
|
123
|
-
}
|
|
124
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
125
|
-
const transactions = [];
|
|
126
|
-
const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
const transfers = [];
|
|
128
|
-
const hasNativeTokenBeingTransferred = item.value !== '0';
|
|
129
|
-
if (hasNativeTokenBeingTransferred) {
|
|
130
|
-
transfers.push({
|
|
131
|
-
amount: ethers_1.ethers.utils.formatUnits(item.value, nativeToken.decimals),
|
|
132
|
-
from: item.from.hash,
|
|
133
|
-
to: item.to.hash,
|
|
134
|
-
type: 'token',
|
|
135
|
-
contractHash: nativeToken.hash,
|
|
136
|
-
token: nativeToken,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
if (item.raw_input) {
|
|
140
|
-
try {
|
|
141
|
-
const ERC20Interface = new ethers_1.ethers.utils.Interface(ERC20_1.ERC20_ABI);
|
|
142
|
-
const result = ERC20Interface.decodeFunctionData('transfer', item.raw_input);
|
|
143
|
-
if (!result)
|
|
144
|
-
throw new Error('Invalid ERC20 transfer');
|
|
145
|
-
const contractHash = item.to.hash;
|
|
146
|
-
const token = yield this.getTokenInfo(contractHash);
|
|
147
|
-
const to = result[0];
|
|
148
|
-
const value = result[1];
|
|
149
|
-
transfers.push({
|
|
150
|
-
amount: ethers_1.ethers.utils.formatUnits(value, token.decimals),
|
|
151
|
-
from: item.from.hash,
|
|
152
|
-
to,
|
|
153
|
-
type: 'token',
|
|
154
|
-
contractHash: item.to.hash,
|
|
155
|
-
token,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
catch (error) {
|
|
159
|
-
/* empty */
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
transactions.push({
|
|
163
|
-
block: item.block,
|
|
164
|
-
hash: item.hash,
|
|
165
|
-
fee: ethers_1.ethers.utils.formatUnits(item.fee.value, nativeToken.decimals),
|
|
166
|
-
time: new Date(item.timestamp).getTime() / 1000,
|
|
167
|
-
notifications: [],
|
|
168
|
-
transfers,
|
|
169
|
-
});
|
|
170
|
-
}));
|
|
171
|
-
yield Promise.allSettled(promises);
|
|
172
|
-
return {
|
|
173
|
-
transactions,
|
|
174
|
-
nextPageParams: data.next_page_params,
|
|
175
|
-
};
|
|
176
|
-
});
|
|
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
|
-
}
|
|
191
|
-
getContract(contractHash) {
|
|
192
|
-
const _super = Object.create(null, {
|
|
193
|
-
getContract: { get: () => super.getContract }
|
|
194
|
-
});
|
|
195
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
197
|
-
return _super.getContract.call(this, contractHash);
|
|
198
|
-
}
|
|
199
|
-
try {
|
|
200
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
201
|
-
const { data } = yield client.get(`/smart-contracts/${contractHash}`);
|
|
202
|
-
if (!data || 'message' in data) {
|
|
203
|
-
throw new Error('Contract not found');
|
|
204
|
-
}
|
|
205
|
-
const methods = [];
|
|
206
|
-
data.abi.forEach(abi => {
|
|
207
|
-
var _a, _b;
|
|
208
|
-
if (abi.type !== 'function')
|
|
209
|
-
return;
|
|
210
|
-
const parameters = (_a = abi.inputs) === null || _a === void 0 ? void 0 : _a.map(param => ({
|
|
211
|
-
name: param.name,
|
|
212
|
-
type: param.type,
|
|
213
|
-
}));
|
|
214
|
-
methods.push({
|
|
215
|
-
name: (_b = abi.name) !== null && _b !== void 0 ? _b : '',
|
|
216
|
-
parameters: parameters !== null && parameters !== void 0 ? parameters : [],
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
return {
|
|
220
|
-
hash: contractHash,
|
|
221
|
-
name: data.name,
|
|
222
|
-
methods,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
catch (error) {
|
|
226
|
-
throw new Error('Contract not found or not supported');
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
getTokenInfo(tokenHash) {
|
|
231
|
-
const _super = Object.create(null, {
|
|
232
|
-
getTokenInfo: { get: () => super.getTokenInfo }
|
|
233
|
-
});
|
|
234
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
236
|
-
return _super.getTokenInfo.call(this, tokenHash);
|
|
237
|
-
}
|
|
238
|
-
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
239
|
-
if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(nativeAsset.hash) === BSEthereumHelper_1.BSEthereumHelper.normalizeHash(tokenHash)) {
|
|
240
|
-
return nativeAsset;
|
|
241
|
-
}
|
|
242
|
-
if (this._tokenCache.has(tokenHash)) {
|
|
243
|
-
return this._tokenCache.get(tokenHash);
|
|
244
|
-
}
|
|
245
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
246
|
-
const { data } = yield client.get(`/tokens/${tokenHash}`);
|
|
247
|
-
if (!data || 'message' in data) {
|
|
248
|
-
throw new Error('Token not found');
|
|
249
|
-
}
|
|
250
|
-
if (data.type !== 'ERC-20') {
|
|
251
|
-
throw new Error('Token is not an ERC-20 token');
|
|
252
|
-
}
|
|
253
|
-
return {
|
|
254
|
-
decimals: data.decimals ? parseInt(data.decimals) : BSEthereumConstants_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
255
|
-
hash: tokenHash,
|
|
256
|
-
name: data.name,
|
|
257
|
-
symbol: data.symbol,
|
|
258
|
-
};
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
getBalance(address) {
|
|
262
|
-
const _super = Object.create(null, {
|
|
263
|
-
getBalance: { get: () => super.getBalance }
|
|
264
|
-
});
|
|
265
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
267
|
-
return _super.getBalance.call(this, address);
|
|
268
|
-
}
|
|
269
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
270
|
-
const { data: nativeBalance } = yield client.get(`/addresses/${address}`);
|
|
271
|
-
if (!nativeBalance || 'message' in nativeBalance) {
|
|
272
|
-
throw new Error('Native balance not found');
|
|
273
|
-
}
|
|
274
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
275
|
-
const balances = [
|
|
276
|
-
{
|
|
277
|
-
amount: ethers_1.ethers.utils.formatUnits(nativeBalance.coin_balance, nativeToken.decimals),
|
|
278
|
-
token: nativeToken,
|
|
279
|
-
},
|
|
280
|
-
];
|
|
281
|
-
const { data: erc20Balances } = yield client.get(`/addresses/${address}/token-balances`);
|
|
282
|
-
if (!erc20Balances || 'message' in erc20Balances) {
|
|
283
|
-
throw new Error('ERC20 balance not found');
|
|
284
|
-
}
|
|
285
|
-
erc20Balances.forEach(balance => {
|
|
286
|
-
try {
|
|
287
|
-
if (balance.token.type !== 'ERC-20') {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
const token = {
|
|
291
|
-
decimals: balance.token.decimals ? parseInt(balance.token.decimals) : BSEthereumConstants_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
292
|
-
hash: balance.token.address,
|
|
293
|
-
name: balance.token.symbol,
|
|
294
|
-
symbol: balance.token.symbol,
|
|
295
|
-
};
|
|
296
|
-
balances.push({
|
|
297
|
-
amount: ethers_1.ethers.utils.formatUnits(balance.value, token.decimals),
|
|
298
|
-
token,
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
catch (_a) {
|
|
302
|
-
/* empty */
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
return balances;
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
getBlockHeight() {
|
|
309
|
-
const _super = Object.create(null, {
|
|
310
|
-
getBlockHeight: { get: () => super.getBlockHeight }
|
|
311
|
-
});
|
|
312
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
-
if (!BlockscoutBDSEthereum.isNeoX(this._network)) {
|
|
314
|
-
return _super.getBlockHeight.call(this);
|
|
315
|
-
}
|
|
316
|
-
const client = BlockscoutBDSEthereum.getClient(this._network);
|
|
317
|
-
const { data } = yield client.get('/blocks');
|
|
318
|
-
if (!data || 'message' in data) {
|
|
319
|
-
throw new Error('Block not found');
|
|
320
|
-
}
|
|
321
|
-
return data.items[0].height;
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
exports.BlockscoutBDSEthereum = BlockscoutBDSEthereum;
|
|
326
|
-
BlockscoutBDSEthereum.BASE_URL_BY_CHAIN_ID = {
|
|
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',
|
|
329
|
-
};
|
|
@@ -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
|
-
}
|
|
@@ -1,67 +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 _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
|
-
};
|