@cityofzion/bs-ethereum 1.2.2 → 1.2.4
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 +1 -1
- package/dist/BitqueryEDSEthereum.d.ts +2 -2
- package/dist/BitqueryEDSEthereum.js +3 -1
- package/dist/GhostMarketNDSEthereum.d.ts +4 -3
- package/dist/GhostMarketNDSEthereum.js +5 -3
- package/dist/RpcBDSEthereum.d.ts +2 -1
- package/dist/RpcBDSEthereum.js +30 -0
- package/dist/RpcNDSEthereum.d.ts +8 -0
- package/dist/RpcNDSEthereum.js +49 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +25 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
package/dist/BSEthereum.js
CHANGED
|
@@ -66,7 +66,7 @@ class BSEthereum {
|
|
|
66
66
|
this.blockchainDataService = new BitqueryBDSEthereum_1.BitqueryBDSEthereum(network);
|
|
67
67
|
}
|
|
68
68
|
this.exchangeDataService = new BitqueryEDSEthereum_1.BitqueryEDSEthereum(network.type);
|
|
69
|
-
this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network
|
|
69
|
+
this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network);
|
|
70
70
|
}
|
|
71
71
|
validateAddress(address) {
|
|
72
72
|
return ethers_1.ethers.utils.isAddress(address);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class BitqueryEDSEthereum implements ExchangeDataService {
|
|
1
|
+
import { CryptoCompareEDS, Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class BitqueryEDSEthereum extends CryptoCompareEDS implements ExchangeDataService {
|
|
3
3
|
#private;
|
|
4
4
|
constructor(networkType: NetworkType);
|
|
5
5
|
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
@@ -25,13 +25,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
var _BitqueryEDSEthereum_client, _BitqueryEDSEthereum_networkType;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.BitqueryEDSEthereum = void 0;
|
|
28
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
28
29
|
const axios_1 = __importDefault(require("axios"));
|
|
29
30
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
30
31
|
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
31
32
|
const constants_1 = require("./constants");
|
|
32
33
|
dayjs_1.default.extend(utc_1.default);
|
|
33
|
-
class BitqueryEDSEthereum {
|
|
34
|
+
class BitqueryEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
|
|
34
35
|
constructor(networkType) {
|
|
36
|
+
super(networkType, constants_1.TOKENS[networkType]);
|
|
35
37
|
_BitqueryEDSEthereum_client.set(this, void 0);
|
|
36
38
|
_BitqueryEDSEthereum_networkType.set(this, void 0);
|
|
37
39
|
__classPrivateFieldSet(this, _BitqueryEDSEthereum_networkType, networkType, "f");
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { NftResponse, NftsResponse,
|
|
2
|
-
|
|
1
|
+
import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { RpcNDSEthereum } from './RpcNDSEthereum';
|
|
3
|
+
export declare class GhostMarketNDSEthereum extends RpcNDSEthereum {
|
|
3
4
|
#private;
|
|
4
|
-
constructor(
|
|
5
|
+
constructor(network: Network);
|
|
5
6
|
getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
6
7
|
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
7
8
|
private treatGhostMarketImage;
|
|
@@ -28,10 +28,12 @@ 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 constants_1 = require("./constants");
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const RpcNDSEthereum_1 = require("./RpcNDSEthereum");
|
|
32
|
+
class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
33
|
+
constructor(network) {
|
|
34
|
+
super(network);
|
|
33
35
|
_GhostMarketNDSEthereum_networkType.set(this, void 0);
|
|
34
|
-
__classPrivateFieldSet(this, _GhostMarketNDSEthereum_networkType,
|
|
36
|
+
__classPrivateFieldSet(this, _GhostMarketNDSEthereum_networkType, network.type, "f");
|
|
35
37
|
}
|
|
36
38
|
getNftsByAddress({ address, size = 18, cursor }) {
|
|
37
39
|
var _a;
|
package/dist/RpcBDSEthereum.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BalanceResponse, BlockchainDataService, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
3
3
|
#private;
|
|
4
4
|
maxTimeToConfirmTransactionInMs: number;
|
|
@@ -9,4 +9,5 @@ export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
|
9
9
|
getTokenInfo(hash: string): Promise<Token>;
|
|
10
10
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
11
11
|
getBlockHeight(): Promise<number>;
|
|
12
|
+
getRpcList(): Promise<RpcResponse[]>;
|
|
12
13
|
}
|
package/dist/RpcBDSEthereum.js
CHANGED
|
@@ -98,6 +98,36 @@ class RpcBDSEthereum {
|
|
|
98
98
|
return yield provider.getBlockNumber();
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
+
getRpcList() {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const list = [];
|
|
104
|
+
const promises = constants_1.RPC_LIST_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").type].map(url => {
|
|
105
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
106
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const timeout = setTimeout(() => {
|
|
108
|
+
resolve();
|
|
109
|
+
}, 5000);
|
|
110
|
+
try {
|
|
111
|
+
const provider = new ethers_1.ethers.providers.JsonRpcProvider(url);
|
|
112
|
+
const timeStart = Date.now();
|
|
113
|
+
const height = yield provider.getBlockNumber();
|
|
114
|
+
const latency = Date.now() - timeStart;
|
|
115
|
+
list.push({
|
|
116
|
+
url,
|
|
117
|
+
height,
|
|
118
|
+
latency,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
resolve();
|
|
123
|
+
clearTimeout(timeout);
|
|
124
|
+
}
|
|
125
|
+
}));
|
|
126
|
+
});
|
|
127
|
+
yield Promise.allSettled(promises);
|
|
128
|
+
return list;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
101
131
|
}
|
|
102
132
|
exports.RpcBDSEthereum = RpcBDSEthereum;
|
|
103
133
|
_RpcBDSEthereum_network = new WeakMap();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GetNftParam, GetNftsByAddressParams, HasTokenParam, Network, NftDataService, NftResponse, NftsResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare abstract class RpcNDSEthereum implements NftDataService {
|
|
3
|
+
#private;
|
|
4
|
+
protected constructor(network: Network);
|
|
5
|
+
abstract getNftsByAddress(params: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
6
|
+
abstract getNft(params: GetNftParam): Promise<NftResponse>;
|
|
7
|
+
hasToken({ contractHash, address }: HasTokenParam): Promise<boolean>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 _RpcNDSEthereum_network;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.RpcNDSEthereum = void 0;
|
|
25
|
+
const ethers_1 = require("ethers");
|
|
26
|
+
class RpcNDSEthereum {
|
|
27
|
+
constructor(network) {
|
|
28
|
+
_RpcNDSEthereum_network.set(this, void 0);
|
|
29
|
+
__classPrivateFieldSet(this, _RpcNDSEthereum_network, network, "f");
|
|
30
|
+
}
|
|
31
|
+
hasToken({ contractHash, address }) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
try {
|
|
34
|
+
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcNDSEthereum_network, "f").url);
|
|
35
|
+
const contract = new ethers_1.ethers.Contract(contractHash, ['function balanceOf(address _owner) external view returns (uint256)'], provider);
|
|
36
|
+
const response = yield contract.balanceOf(address);
|
|
37
|
+
if (!response)
|
|
38
|
+
throw new Error();
|
|
39
|
+
const parsedResponse = response;
|
|
40
|
+
return parsedResponse.gt(0);
|
|
41
|
+
}
|
|
42
|
+
catch (_a) {
|
|
43
|
+
throw new Error(`Token not found: ${contractHash}`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.RpcNDSEthereum = RpcNDSEthereum;
|
|
49
|
+
_RpcNDSEthereum_network = new WeakMap();
|
package/dist/constants.d.ts
CHANGED
|
@@ -7,9 +7,10 @@ export declare const NATIVE_ASSETS: {
|
|
|
7
7
|
hash: string;
|
|
8
8
|
decimals: number;
|
|
9
9
|
}[];
|
|
10
|
-
export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<NetworkType, string>;
|
|
11
10
|
export declare const BITQUERY_MIRROR_URL = "https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/";
|
|
12
11
|
export declare const BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, BitqueryNetwork>;
|
|
13
12
|
export declare const GHOSTMARKET_URL_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
|
|
14
13
|
export declare const GHOSTMARKET_CHAIN_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
|
|
15
14
|
export declare const DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
15
|
+
export declare const RPC_LIST_BY_NETWORK_TYPE: Record<NetworkType, string[]>;
|
|
16
|
+
export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<NetworkType, string>;
|
package/dist/constants.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DERIVATION_PATH = exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = exports.BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE = exports.BITQUERY_MIRROR_URL = exports.
|
|
6
|
+
exports.DEFAULT_URL_BY_NETWORK_TYPE = exports.RPC_LIST_BY_NETWORK_TYPE = exports.DERIVATION_PATH = exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = exports.BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE = exports.BITQUERY_MIRROR_URL = exports.NATIVE_ASSETS = exports.TOKENS = void 0;
|
|
7
7
|
const common_json_1 = __importDefault(require("./assets/tokens/common.json"));
|
|
8
8
|
exports.TOKENS = {
|
|
9
9
|
mainnet: [...common_json_1.default],
|
|
@@ -11,11 +11,6 @@ exports.TOKENS = {
|
|
|
11
11
|
custom: common_json_1.default,
|
|
12
12
|
};
|
|
13
13
|
exports.NATIVE_ASSETS = common_json_1.default;
|
|
14
|
-
exports.DEFAULT_URL_BY_NETWORK_TYPE = {
|
|
15
|
-
mainnet: 'https://ethereum-mainnet-rpc.allthatnode.com',
|
|
16
|
-
testnet: 'https://ethereum-sepolia-rpc.publicnode.com',
|
|
17
|
-
custom: 'http://127.0.0.1:8545',
|
|
18
|
-
};
|
|
19
14
|
exports.BITQUERY_MIRROR_URL = 'https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/';
|
|
20
15
|
exports.BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE = {
|
|
21
16
|
mainnet: 'ethereum',
|
|
@@ -30,3 +25,27 @@ exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = {
|
|
|
30
25
|
testnet: 'etht',
|
|
31
26
|
};
|
|
32
27
|
exports.DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
28
|
+
exports.RPC_LIST_BY_NETWORK_TYPE = {
|
|
29
|
+
mainnet: [
|
|
30
|
+
'https://ethereum-mainnet-rpc.allthatnode.com',
|
|
31
|
+
'https://eth.llamarpc.com',
|
|
32
|
+
'https://ethereum-rpc.publicnode.com',
|
|
33
|
+
'https://endpoints.omniatech.io/v1/eth/mainnet/public',
|
|
34
|
+
'https://rpc.flashbots.net',
|
|
35
|
+
'https://rpc.mevblocker.io',
|
|
36
|
+
],
|
|
37
|
+
testnet: [
|
|
38
|
+
'https://ethereum-sepolia-rpc.publicnode.com',
|
|
39
|
+
'https://endpoints.omniatech.io/v1/eth/sepolia/public',
|
|
40
|
+
'https://eth-sepolia.public.blastapi.io',
|
|
41
|
+
'https://eth-sepolia-public.unifra.io',
|
|
42
|
+
'https://1rpc.io/sepolia',
|
|
43
|
+
'https://eth-sepolia.api.onfinality.io/public',
|
|
44
|
+
],
|
|
45
|
+
custom: ['http://127.0.0.1:8545'],
|
|
46
|
+
};
|
|
47
|
+
exports.DEFAULT_URL_BY_NETWORK_TYPE = {
|
|
48
|
+
mainnet: exports.RPC_LIST_BY_NETWORK_TYPE.mainnet[0],
|
|
49
|
+
testnet: exports.RPC_LIST_BY_NETWORK_TYPE.testnet[0],
|
|
50
|
+
custom: exports.RPC_LIST_BY_NETWORK_TYPE.custom[0],
|
|
51
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -20,3 +20,4 @@ __exportStar(require("./constants"), exports);
|
|
|
20
20
|
__exportStar(require("./BitqueryBDSEthereum"), exports);
|
|
21
21
|
__exportStar(require("./BitqueryEDSEthereum"), exports);
|
|
22
22
|
__exportStar(require("./RpcBDSEthereum"), exports);
|
|
23
|
+
__exportStar(require("./RpcNDSEthereum"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
22
22
|
"@ledgerhq/hw-transport": "~6.30.5",
|
|
23
23
|
"@ledgerhq/hw-app-eth": "~6.35.7",
|
|
24
|
-
"@cityofzion/blockchain-service": "0.11.
|
|
24
|
+
"@cityofzion/blockchain-service": "0.11.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/jest": "29.5.3",
|