@cityofzion/bs-ethereum 1.4.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BSEthereum.d.ts +6 -5
- package/dist/BSEthereum.js +13 -16
- package/dist/BitqueryBDSEthereum.d.ts +2 -1
- package/dist/BitqueryBDSEthereum.js +24 -23
- package/dist/BitqueryEDSEthereum.d.ts +3 -2
- package/dist/BitqueryEDSEthereum.js +7 -9
- package/dist/GhostMarketNDSEthereum.d.ts +2 -1
- package/dist/GhostMarketNDSEthereum.js +7 -7
- package/dist/RpcBDSEthereum.d.ts +2 -1
- package/dist/RpcBDSEthereum.js +19 -10
- package/dist/assets/abis/ERC20.d.ts +38 -0
- package/dist/assets/abis/ERC20.js +225 -0
- package/dist/assets/tokens/index.d.ts +9 -0
- package/dist/assets/tokens/index.js +51 -0
- package/dist/constants.d.ts +10 -15
- package/dist/constants.js +142 -34
- package/package.json +3 -3
- package/dist/assets/tokens/common.json +0 -8
package/dist/BSEthereum.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Account, AccountWithDerivationPath, BSCalculableFee, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, Network, NftDataService,
|
|
1
|
+
import { Account, AccountWithDerivationPath, BSCalculableFee, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, Network, NftDataService, PartialNetwork, Token, TransferParam } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { LedgerServiceEthereum } from './LedgerServiceEthereum';
|
|
3
3
|
import Transport from '@ledgerhq/hw-transport';
|
|
4
|
-
|
|
4
|
+
import { AvailableNetworkIds } from './constants';
|
|
5
|
+
export declare class BSEthereum<BSCustomName extends string = string> implements BlockchainService<BSCustomName, AvailableNetworkIds>, BSWithNft, BSWithNameService, BSCalculableFee, BSWithLedger {
|
|
5
6
|
readonly blockchainName: BSCustomName;
|
|
6
7
|
readonly feeToken: Token;
|
|
7
8
|
readonly derivationPath: string;
|
|
@@ -10,9 +11,9 @@ export declare class BSEthereum<BSCustomName extends string = string> implements
|
|
|
10
11
|
ledgerService: LedgerServiceEthereum;
|
|
11
12
|
tokens: Token[];
|
|
12
13
|
nftDataService: NftDataService;
|
|
13
|
-
network: Network
|
|
14
|
-
constructor(blockchainName: BSCustomName, network:
|
|
15
|
-
setNetwork(
|
|
14
|
+
network: Network<AvailableNetworkIds>;
|
|
15
|
+
constructor(blockchainName: BSCustomName, network: PartialNetwork<AvailableNetworkIds>, getLedgerTransport?: (account: Account) => Promise<Transport>);
|
|
16
|
+
setNetwork(partialNetwork: PartialNetwork<AvailableNetworkIds>): void;
|
|
16
17
|
validateAddress(address: string): boolean;
|
|
17
18
|
validateEncrypted(json: string): boolean;
|
|
18
19
|
validateKey(key: string): boolean;
|
package/dist/BSEthereum.js
CHANGED
|
@@ -37,35 +37,32 @@ const ethers_1 = require("ethers");
|
|
|
37
37
|
const ethersJsonWallets = __importStar(require("@ethersproject/json-wallets"));
|
|
38
38
|
const ethersBytes = __importStar(require("@ethersproject/bytes"));
|
|
39
39
|
const ethersBigNumber = __importStar(require("@ethersproject/bignumber"));
|
|
40
|
-
const constants_1 = require("./constants");
|
|
41
40
|
const BitqueryEDSEthereum_1 = require("./BitqueryEDSEthereum");
|
|
42
41
|
const GhostMarketNDSEthereum_1 = require("./GhostMarketNDSEthereum");
|
|
43
42
|
const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
44
43
|
const BitqueryBDSEthereum_1 = require("./BitqueryBDSEthereum");
|
|
45
44
|
const LedgerServiceEthereum_1 = require("./LedgerServiceEthereum");
|
|
45
|
+
const constants_1 = require("./constants");
|
|
46
46
|
class BSEthereum {
|
|
47
47
|
constructor(blockchainName, network, getLedgerTransport) {
|
|
48
48
|
this.blockchainName = blockchainName;
|
|
49
49
|
this.ledgerService = new LedgerServiceEthereum_1.LedgerServiceEthereum(getLedgerTransport);
|
|
50
50
|
this.derivationPath = constants_1.DERIVATION_PATH;
|
|
51
|
-
this.tokens = constants_1.
|
|
52
|
-
this.feeToken =
|
|
51
|
+
this.tokens = [constants_1.NATIVE_ASSET_BY_NETWORK_ID[network.id]];
|
|
52
|
+
this.feeToken = constants_1.NATIVE_ASSET_BY_NETWORK_ID[network.id];
|
|
53
53
|
this.setNetwork(network);
|
|
54
54
|
}
|
|
55
|
-
setNetwork(
|
|
56
|
-
var _a;
|
|
55
|
+
setNetwork(partialNetwork) {
|
|
56
|
+
var _a, _b;
|
|
57
57
|
const network = {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
id: partialNetwork.id,
|
|
59
|
+
name: (_a = partialNetwork.name) !== null && _a !== void 0 ? _a : constants_1.NETWORK_NAME_BY_NETWORK_ID[partialNetwork.id],
|
|
60
|
+
url: (_b = partialNetwork.url) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_URL_BY_NETWORK_ID[partialNetwork.id],
|
|
60
61
|
};
|
|
61
62
|
this.network = network;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
else {
|
|
66
|
-
this.blockchainDataService = new BitqueryBDSEthereum_1.BitqueryBDSEthereum(network);
|
|
67
|
-
}
|
|
68
|
-
this.exchangeDataService = new BitqueryEDSEthereum_1.BitqueryEDSEthereum(network.type);
|
|
63
|
+
const bitqueryNetwork = constants_1.BITQUERY_MIRROR_NETWORK_BY_NETWORK_ID[partialNetwork.id];
|
|
64
|
+
this.blockchainDataService = bitqueryNetwork ? new BitqueryBDSEthereum_1.BitqueryBDSEthereum(network) : new RpcBDSEthereum_1.RpcBDSEthereum(network);
|
|
65
|
+
this.exchangeDataService = new BitqueryEDSEthereum_1.BitqueryEDSEthereum(network.id);
|
|
69
66
|
this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network);
|
|
70
67
|
}
|
|
71
68
|
validateAddress(address) {
|
|
@@ -154,7 +151,7 @@ class BSEthereum {
|
|
|
154
151
|
const decimals = (_a = param.intent.tokenDecimals) !== null && _a !== void 0 ? _a : 18;
|
|
155
152
|
const amount = ethersBigNumber.parseFixed(param.intent.amount, decimals);
|
|
156
153
|
let transactionParams;
|
|
157
|
-
const isNative = constants_1.
|
|
154
|
+
const isNative = constants_1.NATIVE_ASSET_BY_NETWORK_ID[this.network.id].hash === param.intent.tokenHash;
|
|
158
155
|
if (isNative) {
|
|
159
156
|
transactionParams = {
|
|
160
157
|
to: param.intent.receiverAddress,
|
|
@@ -190,7 +187,7 @@ class BSEthereum {
|
|
|
190
187
|
}
|
|
191
188
|
const gasPrice = yield provider.getGasPrice();
|
|
192
189
|
let estimated;
|
|
193
|
-
const isNative = constants_1.
|
|
190
|
+
const isNative = constants_1.NATIVE_ASSET_BY_NETWORK_ID[this.network.id].hash === param.intent.tokenHash;
|
|
194
191
|
const decimals = (_a = param.intent.tokenDecimals) !== null && _a !== void 0 ? _a : 18;
|
|
195
192
|
const amount = ethersBigNumber.parseFixed(param.intent.amount, decimals);
|
|
196
193
|
if (!isNative) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BalanceResponse, ContractResponse, Token, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, Network } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './constants';
|
|
2
3
|
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
3
4
|
export declare class BitqueryBDSEthereum extends RpcBDSEthereum {
|
|
4
5
|
#private;
|
|
5
6
|
maxTimeToConfirmTransactionInMs: number;
|
|
6
|
-
constructor(network: Network);
|
|
7
|
+
constructor(network: Network<AvailableNetworkIds>);
|
|
7
8
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
8
9
|
getTransactionsByAddress({ address, page, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
9
10
|
getContract(): Promise<ContractResponse>;
|
|
@@ -22,7 +22,7 @@ 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 _BitqueryBDSEthereum_client,
|
|
25
|
+
var _BitqueryBDSEthereum_client, _BitqueryBDSEthereum_networkId, _BitqueryBDSEthereum_tokenCache;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.BitqueryBDSEthereum = void 0;
|
|
28
28
|
const constants_1 = require("./constants");
|
|
@@ -32,11 +32,10 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
32
32
|
constructor(network) {
|
|
33
33
|
super(network);
|
|
34
34
|
_BitqueryBDSEthereum_client.set(this, void 0);
|
|
35
|
-
|
|
35
|
+
_BitqueryBDSEthereum_networkId.set(this, void 0);
|
|
36
|
+
_BitqueryBDSEthereum_tokenCache.set(this, new Map());
|
|
36
37
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 8;
|
|
37
|
-
|
|
38
|
-
throw new Error('Custom network not supported');
|
|
39
|
-
__classPrivateFieldSet(this, _BitqueryBDSEthereum_networkType, network.type, "f");
|
|
38
|
+
__classPrivateFieldSet(this, _BitqueryBDSEthereum_networkId, network.id, "f");
|
|
40
39
|
__classPrivateFieldSet(this, _BitqueryBDSEthereum_client, axios_1.default.create({
|
|
41
40
|
baseURL: constants_1.BITQUERY_MIRROR_URL,
|
|
42
41
|
}), "f");
|
|
@@ -44,7 +43,7 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
44
43
|
getTransaction(hash) {
|
|
45
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
45
|
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-transaction/${hash}`, {
|
|
47
|
-
params: { network: constants_1.
|
|
46
|
+
params: { network: constants_1.BITQUERY_MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkId, "f")] },
|
|
48
47
|
});
|
|
49
48
|
if (!result.data || !result.data.ethereum.transfers.length)
|
|
50
49
|
throw new Error('Transaction not found');
|
|
@@ -66,7 +65,7 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
66
65
|
const limit = 10;
|
|
67
66
|
const offset = limit * (page - 1);
|
|
68
67
|
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-transactions/${address}`, {
|
|
69
|
-
params: { network: constants_1.
|
|
68
|
+
params: { network: constants_1.BITQUERY_MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkId, "f")], limit, offset },
|
|
70
69
|
});
|
|
71
70
|
if (!result.data)
|
|
72
71
|
throw new Error('Address does not have transactions');
|
|
@@ -103,42 +102,44 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
103
102
|
}
|
|
104
103
|
getTokenInfo(hash) {
|
|
105
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
if (__classPrivateFieldGet(this, _BitqueryBDSEthereum_tokenCache, "f").has(hash)) {
|
|
106
|
+
return __classPrivateFieldGet(this, _BitqueryBDSEthereum_tokenCache, "f").get(hash);
|
|
107
|
+
}
|
|
109
108
|
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-token-info/${hash}`, {
|
|
110
|
-
params: { network: constants_1.
|
|
109
|
+
params: { network: constants_1.BITQUERY_MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkId, "f")] },
|
|
111
110
|
});
|
|
112
111
|
if (!result.data || result.data.ethereum.smartContractCalls.length <= 0)
|
|
113
112
|
throw new Error('Token not found');
|
|
114
113
|
const { address: { address }, currency: { decimals, name, symbol, tokenType }, } = result.data.ethereum.smartContractCalls[0].smartContract;
|
|
115
114
|
if (tokenType !== 'ERC20')
|
|
116
115
|
throw new Error('Token is not ERC20');
|
|
117
|
-
|
|
116
|
+
const token = {
|
|
118
117
|
hash: address,
|
|
119
|
-
name,
|
|
120
118
|
symbol,
|
|
121
119
|
decimals,
|
|
120
|
+
name,
|
|
122
121
|
};
|
|
122
|
+
__classPrivateFieldGet(this, _BitqueryBDSEthereum_tokenCache, "f").set(hash, token);
|
|
123
|
+
return token;
|
|
123
124
|
});
|
|
124
125
|
}
|
|
125
126
|
getBalance(address) {
|
|
126
127
|
var _a, _b, _c, _d;
|
|
127
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
129
|
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-balance/${address}`, {
|
|
129
|
-
params: { network: constants_1.
|
|
130
|
+
params: { network: constants_1.BITQUERY_MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkId, "f")] },
|
|
130
131
|
});
|
|
131
132
|
const data = (_b = (_a = result.data) === null || _a === void 0 ? void 0 : _a.ethereum.address[0].balances) !== null && _b !== void 0 ? _b : [];
|
|
132
|
-
const
|
|
133
|
-
const
|
|
133
|
+
const nativeBalance = (_d = (_c = result.data) === null || _c === void 0 ? void 0 : _c.ethereum.address[0].balance) !== null && _d !== void 0 ? _d : 0;
|
|
134
|
+
const nativeToken = constants_1.NATIVE_ASSET_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkId, "f")];
|
|
134
135
|
const balances = [
|
|
135
136
|
{
|
|
136
|
-
amount:
|
|
137
|
-
token:
|
|
137
|
+
amount: nativeBalance.toString(),
|
|
138
|
+
token: nativeToken,
|
|
138
139
|
},
|
|
139
140
|
];
|
|
140
|
-
data.forEach(({ value, currency: { address, decimals,
|
|
141
|
-
if (value < 0 || address ===
|
|
141
|
+
data.forEach(({ value, currency: { address, decimals, symbol, name } }) => {
|
|
142
|
+
if (value < 0 || address === nativeToken.hash)
|
|
142
143
|
return;
|
|
143
144
|
balances.push({
|
|
144
145
|
amount: value.toString(),
|
|
@@ -153,7 +154,7 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
153
154
|
return balances;
|
|
154
155
|
});
|
|
155
156
|
}
|
|
156
|
-
parseTransactionTransfer({ amount, currency: { tokenType, address, decimals,
|
|
157
|
+
parseTransactionTransfer({ amount, currency: { tokenType, address, decimals, symbol, name }, entityId, sender, receiver, }) {
|
|
157
158
|
if (tokenType === 'ERC721') {
|
|
158
159
|
return {
|
|
159
160
|
from: sender.address,
|
|
@@ -171,12 +172,12 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
171
172
|
token: {
|
|
172
173
|
decimals: decimals,
|
|
173
174
|
hash: address,
|
|
174
|
-
name: name,
|
|
175
175
|
symbol: symbol,
|
|
176
|
+
name: name,
|
|
176
177
|
},
|
|
177
178
|
type: 'token',
|
|
178
179
|
};
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
exports.BitqueryBDSEthereum = BitqueryBDSEthereum;
|
|
182
|
-
_BitqueryBDSEthereum_client = new WeakMap(),
|
|
183
|
+
_BitqueryBDSEthereum_client = new WeakMap(), _BitqueryBDSEthereum_networkId = new WeakMap(), _BitqueryBDSEthereum_tokenCache = new WeakMap();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CryptoCompareEDS, Currency, ExchangeDataService,
|
|
1
|
+
import { CryptoCompareEDS, Currency, ExchangeDataService, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './constants';
|
|
2
3
|
export declare class BitqueryEDSEthereum extends CryptoCompareEDS implements ExchangeDataService {
|
|
3
4
|
#private;
|
|
4
|
-
constructor(
|
|
5
|
+
constructor(networkId: AvailableNetworkIds);
|
|
5
6
|
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
6
7
|
private getCurrencyRatio;
|
|
7
8
|
}
|
|
@@ -22,7 +22,7 @@ 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 _BitqueryEDSEthereum_client,
|
|
25
|
+
var _BitqueryEDSEthereum_client, _BitqueryEDSEthereum_networkId;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.BitqueryEDSEthereum = void 0;
|
|
28
28
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
@@ -32,22 +32,20 @@ const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
|
32
32
|
const constants_1 = require("./constants");
|
|
33
33
|
dayjs_1.default.extend(utc_1.default);
|
|
34
34
|
class BitqueryEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
|
|
35
|
-
constructor(
|
|
36
|
-
super(
|
|
35
|
+
constructor(networkId) {
|
|
36
|
+
super([constants_1.NATIVE_ASSET_BY_NETWORK_ID[networkId]]);
|
|
37
37
|
_BitqueryEDSEthereum_client.set(this, void 0);
|
|
38
|
-
|
|
39
|
-
__classPrivateFieldSet(this,
|
|
38
|
+
_BitqueryEDSEthereum_networkId.set(this, void 0);
|
|
39
|
+
__classPrivateFieldSet(this, _BitqueryEDSEthereum_networkId, networkId, "f");
|
|
40
40
|
__classPrivateFieldSet(this, _BitqueryEDSEthereum_client, axios_1.default.create({
|
|
41
41
|
baseURL: constants_1.BITQUERY_MIRROR_URL,
|
|
42
42
|
}), "f");
|
|
43
43
|
}
|
|
44
44
|
getTokenPrices(currency) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
if (__classPrivateFieldGet(this, _BitqueryEDSEthereum_networkType, "f") !== 'mainnet')
|
|
47
|
-
throw new Error('Exchange is only available on mainnet');
|
|
48
46
|
const twoDaysAgo = dayjs_1.default.utc().subtract(2, 'day').startOf('date').toISOString();
|
|
49
47
|
const result = yield __classPrivateFieldGet(this, _BitqueryEDSEthereum_client, "f").get(`/get-price`, {
|
|
50
|
-
params: { network: constants_1.
|
|
48
|
+
params: { network: constants_1.BITQUERY_MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryEDSEthereum_networkId, "f")], after: twoDaysAgo },
|
|
51
49
|
});
|
|
52
50
|
if (!result.data) {
|
|
53
51
|
throw new Error('There is no price data');
|
|
@@ -72,4 +70,4 @@ class BitqueryEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
|
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
exports.BitqueryEDSEthereum = BitqueryEDSEthereum;
|
|
75
|
-
_BitqueryEDSEthereum_client = new WeakMap(),
|
|
73
|
+
_BitqueryEDSEthereum_client = new WeakMap(), _BitqueryEDSEthereum_networkId = new WeakMap();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { RpcNDSEthereum } from './RpcNDSEthereum';
|
|
3
|
+
import { AvailableNetworkIds } from './constants';
|
|
3
4
|
export declare class GhostMarketNDSEthereum extends RpcNDSEthereum {
|
|
4
5
|
#private;
|
|
5
|
-
constructor(network: Network);
|
|
6
|
+
constructor(network: Network<AvailableNetworkIds>);
|
|
6
7
|
getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
7
8
|
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
8
9
|
private treatGhostMarketImage;
|
|
@@ -22,18 +22,18 @@ 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
|
|
25
|
+
var _GhostMarketNDSEthereum_networkId;
|
|
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
|
-
const constants_1 = require("./constants");
|
|
31
30
|
const RpcNDSEthereum_1 = require("./RpcNDSEthereum");
|
|
31
|
+
const constants_1 = require("./constants");
|
|
32
32
|
class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
33
33
|
constructor(network) {
|
|
34
34
|
super(network);
|
|
35
|
-
|
|
36
|
-
__classPrivateFieldSet(this,
|
|
35
|
+
_GhostMarketNDSEthereum_networkId.set(this, void 0);
|
|
36
|
+
__classPrivateFieldSet(this, _GhostMarketNDSEthereum_networkId, network.id, "f");
|
|
37
37
|
}
|
|
38
38
|
getNftsByAddress({ address, size = 18, cursor }) {
|
|
39
39
|
var _a;
|
|
@@ -69,8 +69,8 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
|
69
69
|
return srcImage;
|
|
70
70
|
}
|
|
71
71
|
getUrlWithParams(params) {
|
|
72
|
-
const parameters = query_string_1.default.stringify(Object.assign({ chain: constants_1.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE[__classPrivateFieldGet(this,
|
|
73
|
-
return `${constants_1.GHOSTMARKET_URL_BY_NETWORK_TYPE[__classPrivateFieldGet(this,
|
|
72
|
+
const parameters = query_string_1.default.stringify(Object.assign({ chain: constants_1.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _GhostMarketNDSEthereum_networkId, "f")] }, params), { arrayFormat: 'bracket' });
|
|
73
|
+
return `${constants_1.GHOSTMARKET_URL_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _GhostMarketNDSEthereum_networkId, "f")]}/assets?${parameters}`;
|
|
74
74
|
}
|
|
75
75
|
parse(data) {
|
|
76
76
|
var _a, _b;
|
|
@@ -92,4 +92,4 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
exports.GhostMarketNDSEthereum = GhostMarketNDSEthereum;
|
|
95
|
-
|
|
95
|
+
_GhostMarketNDSEthereum_networkId = new WeakMap();
|
package/dist/RpcBDSEthereum.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './constants';
|
|
2
3
|
export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
3
4
|
#private;
|
|
4
5
|
maxTimeToConfirmTransactionInMs: number;
|
|
5
|
-
constructor(network: Network);
|
|
6
|
+
constructor(network: Network<AvailableNetworkIds>);
|
|
6
7
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
7
8
|
getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
8
9
|
getContract(): Promise<ContractResponse>;
|
package/dist/RpcBDSEthereum.js
CHANGED
|
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
exports.RpcBDSEthereum = void 0;
|
|
25
25
|
const ethers_1 = require("ethers");
|
|
26
26
|
const constants_1 = require("./constants");
|
|
27
|
+
const ERC20_1 = require("./assets/abis/ERC20");
|
|
27
28
|
class RpcBDSEthereum {
|
|
28
29
|
constructor(network) {
|
|
29
30
|
_RpcBDSEthereum_network.set(this, void 0);
|
|
@@ -39,8 +40,7 @@ class RpcBDSEthereum {
|
|
|
39
40
|
const block = yield provider.getBlock(transaction.blockHash);
|
|
40
41
|
if (!block)
|
|
41
42
|
throw new Error('Block not found');
|
|
42
|
-
const
|
|
43
|
-
const token = tokens.find(token => token.symbol === 'ETH');
|
|
43
|
+
const token = constants_1.NATIVE_ASSET_BY_NETWORK_ID[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").id];
|
|
44
44
|
return {
|
|
45
45
|
block: block.number,
|
|
46
46
|
time: block.timestamp,
|
|
@@ -71,19 +71,25 @@ class RpcBDSEthereum {
|
|
|
71
71
|
}
|
|
72
72
|
getTokenInfo(hash) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
if (constants_1.NATIVE_ASSET_BY_NETWORK_ID[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").id].hash === hash)
|
|
75
|
+
return constants_1.NATIVE_ASSET_BY_NETWORK_ID[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").id];
|
|
76
|
+
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").url);
|
|
77
|
+
const contract = new ethers_1.ethers.Contract(hash, ERC20_1.ERC20_ABI, provider);
|
|
78
|
+
const decimals = yield contract.decimals();
|
|
79
|
+
const symbol = yield contract.symbol();
|
|
80
|
+
return {
|
|
81
|
+
decimals,
|
|
82
|
+
symbol,
|
|
83
|
+
hash,
|
|
84
|
+
name: symbol,
|
|
85
|
+
};
|
|
79
86
|
});
|
|
80
87
|
}
|
|
81
88
|
getBalance(address) {
|
|
82
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
90
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").url);
|
|
84
91
|
const balance = yield provider.getBalance(address);
|
|
85
|
-
const
|
|
86
|
-
const token = tokens.find(token => token.symbol === 'ETH');
|
|
92
|
+
const token = constants_1.NATIVE_ASSET_BY_NETWORK_ID[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").id];
|
|
87
93
|
return [
|
|
88
94
|
{
|
|
89
95
|
amount: ethers_1.ethers.utils.formatEther(balance),
|
|
@@ -101,7 +107,7 @@ class RpcBDSEthereum {
|
|
|
101
107
|
getRpcList() {
|
|
102
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
109
|
const list = [];
|
|
104
|
-
const promises = constants_1.
|
|
110
|
+
const promises = constants_1.RPC_LIST_BY_NETWORK_ID[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").id].map(url => {
|
|
105
111
|
// eslint-disable-next-line no-async-promise-executor
|
|
106
112
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
107
113
|
const timeout = setTimeout(() => {
|
|
@@ -118,6 +124,9 @@ class RpcBDSEthereum {
|
|
|
118
124
|
latency,
|
|
119
125
|
});
|
|
120
126
|
}
|
|
127
|
+
catch (_a) {
|
|
128
|
+
/* empty */
|
|
129
|
+
}
|
|
121
130
|
finally {
|
|
122
131
|
resolve();
|
|
123
132
|
clearTimeout(timeout);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const ERC20_ABI: ({
|
|
2
|
+
constant: boolean;
|
|
3
|
+
inputs: {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}[];
|
|
7
|
+
name: string;
|
|
8
|
+
outputs: {
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}[];
|
|
12
|
+
payable: boolean;
|
|
13
|
+
stateMutability: string;
|
|
14
|
+
type: string;
|
|
15
|
+
anonymous?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
payable: boolean;
|
|
18
|
+
stateMutability: string;
|
|
19
|
+
type: string;
|
|
20
|
+
constant?: undefined;
|
|
21
|
+
inputs?: undefined;
|
|
22
|
+
name?: undefined;
|
|
23
|
+
outputs?: undefined;
|
|
24
|
+
anonymous?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
anonymous: boolean;
|
|
27
|
+
inputs: {
|
|
28
|
+
indexed: boolean;
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}[];
|
|
32
|
+
name: string;
|
|
33
|
+
type: string;
|
|
34
|
+
constant?: undefined;
|
|
35
|
+
outputs?: undefined;
|
|
36
|
+
payable?: undefined;
|
|
37
|
+
stateMutability?: undefined;
|
|
38
|
+
})[];
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERC20_ABI = void 0;
|
|
4
|
+
exports.ERC20_ABI = [
|
|
5
|
+
{
|
|
6
|
+
constant: true,
|
|
7
|
+
inputs: [],
|
|
8
|
+
name: 'name',
|
|
9
|
+
outputs: [
|
|
10
|
+
{
|
|
11
|
+
name: '',
|
|
12
|
+
type: 'string',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
payable: false,
|
|
16
|
+
stateMutability: 'view',
|
|
17
|
+
type: 'function',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
constant: false,
|
|
21
|
+
inputs: [
|
|
22
|
+
{
|
|
23
|
+
name: '_spender',
|
|
24
|
+
type: 'address',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: '_value',
|
|
28
|
+
type: 'uint256',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
name: 'approve',
|
|
32
|
+
outputs: [
|
|
33
|
+
{
|
|
34
|
+
name: '',
|
|
35
|
+
type: 'bool',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
payable: false,
|
|
39
|
+
stateMutability: 'nonpayable',
|
|
40
|
+
type: 'function',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
constant: true,
|
|
44
|
+
inputs: [],
|
|
45
|
+
name: 'totalSupply',
|
|
46
|
+
outputs: [
|
|
47
|
+
{
|
|
48
|
+
name: '',
|
|
49
|
+
type: 'uint256',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
payable: false,
|
|
53
|
+
stateMutability: 'view',
|
|
54
|
+
type: 'function',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
constant: false,
|
|
58
|
+
inputs: [
|
|
59
|
+
{
|
|
60
|
+
name: '_from',
|
|
61
|
+
type: 'address',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: '_to',
|
|
65
|
+
type: 'address',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: '_value',
|
|
69
|
+
type: 'uint256',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
name: 'transferFrom',
|
|
73
|
+
outputs: [
|
|
74
|
+
{
|
|
75
|
+
name: '',
|
|
76
|
+
type: 'bool',
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
payable: false,
|
|
80
|
+
stateMutability: 'nonpayable',
|
|
81
|
+
type: 'function',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
constant: true,
|
|
85
|
+
inputs: [],
|
|
86
|
+
name: 'decimals',
|
|
87
|
+
outputs: [
|
|
88
|
+
{
|
|
89
|
+
name: '',
|
|
90
|
+
type: 'uint8',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
payable: false,
|
|
94
|
+
stateMutability: 'view',
|
|
95
|
+
type: 'function',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
constant: true,
|
|
99
|
+
inputs: [
|
|
100
|
+
{
|
|
101
|
+
name: '_owner',
|
|
102
|
+
type: 'address',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
name: 'balanceOf',
|
|
106
|
+
outputs: [
|
|
107
|
+
{
|
|
108
|
+
name: 'balance',
|
|
109
|
+
type: 'uint256',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
payable: false,
|
|
113
|
+
stateMutability: 'view',
|
|
114
|
+
type: 'function',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
constant: true,
|
|
118
|
+
inputs: [],
|
|
119
|
+
name: 'symbol',
|
|
120
|
+
outputs: [
|
|
121
|
+
{
|
|
122
|
+
name: '',
|
|
123
|
+
type: 'string',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
payable: false,
|
|
127
|
+
stateMutability: 'view',
|
|
128
|
+
type: 'function',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
constant: false,
|
|
132
|
+
inputs: [
|
|
133
|
+
{
|
|
134
|
+
name: '_to',
|
|
135
|
+
type: 'address',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: '_value',
|
|
139
|
+
type: 'uint256',
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
name: 'transfer',
|
|
143
|
+
outputs: [
|
|
144
|
+
{
|
|
145
|
+
name: '',
|
|
146
|
+
type: 'bool',
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
payable: false,
|
|
150
|
+
stateMutability: 'nonpayable',
|
|
151
|
+
type: 'function',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
constant: true,
|
|
155
|
+
inputs: [
|
|
156
|
+
{
|
|
157
|
+
name: '_owner',
|
|
158
|
+
type: 'address',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: '_spender',
|
|
162
|
+
type: 'address',
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
name: 'allowance',
|
|
166
|
+
outputs: [
|
|
167
|
+
{
|
|
168
|
+
name: '',
|
|
169
|
+
type: 'uint256',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
payable: false,
|
|
173
|
+
stateMutability: 'view',
|
|
174
|
+
type: 'function',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
payable: true,
|
|
178
|
+
stateMutability: 'payable',
|
|
179
|
+
type: 'fallback',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
anonymous: false,
|
|
183
|
+
inputs: [
|
|
184
|
+
{
|
|
185
|
+
indexed: true,
|
|
186
|
+
name: 'owner',
|
|
187
|
+
type: 'address',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
indexed: true,
|
|
191
|
+
name: 'spender',
|
|
192
|
+
type: 'address',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
indexed: false,
|
|
196
|
+
name: 'value',
|
|
197
|
+
type: 'uint256',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
name: 'Approval',
|
|
201
|
+
type: 'event',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
anonymous: false,
|
|
205
|
+
inputs: [
|
|
206
|
+
{
|
|
207
|
+
indexed: true,
|
|
208
|
+
name: 'from',
|
|
209
|
+
type: 'address',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
indexed: true,
|
|
213
|
+
name: 'to',
|
|
214
|
+
type: 'address',
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
indexed: false,
|
|
218
|
+
name: 'value',
|
|
219
|
+
type: 'uint256',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
name: 'Transfer',
|
|
223
|
+
type: 'event',
|
|
224
|
+
},
|
|
225
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Token } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare const ETH: Token;
|
|
3
|
+
export declare const MATIC: Token;
|
|
4
|
+
export declare const BNB: Token;
|
|
5
|
+
export declare const FTM: Token;
|
|
6
|
+
export declare const CELO: Token;
|
|
7
|
+
export declare const AVAX: Token;
|
|
8
|
+
export declare const CRO: Token;
|
|
9
|
+
export declare const GAS: Token;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GAS = exports.CRO = exports.AVAX = exports.CELO = exports.FTM = exports.BNB = exports.MATIC = exports.ETH = void 0;
|
|
4
|
+
exports.ETH = {
|
|
5
|
+
symbol: 'ETH',
|
|
6
|
+
hash: '-',
|
|
7
|
+
decimals: 18,
|
|
8
|
+
name: 'ETH',
|
|
9
|
+
};
|
|
10
|
+
exports.MATIC = {
|
|
11
|
+
symbol: 'MATIC',
|
|
12
|
+
hash: '-',
|
|
13
|
+
decimals: 18,
|
|
14
|
+
name: 'MATIC',
|
|
15
|
+
};
|
|
16
|
+
exports.BNB = {
|
|
17
|
+
symbol: 'BNB',
|
|
18
|
+
hash: '-',
|
|
19
|
+
decimals: 18,
|
|
20
|
+
name: 'BNB',
|
|
21
|
+
};
|
|
22
|
+
exports.FTM = {
|
|
23
|
+
symbol: 'FTM',
|
|
24
|
+
hash: '-',
|
|
25
|
+
decimals: 18,
|
|
26
|
+
name: 'FTM',
|
|
27
|
+
};
|
|
28
|
+
exports.CELO = {
|
|
29
|
+
symbol: 'CELO',
|
|
30
|
+
hash: '-',
|
|
31
|
+
decimals: 18,
|
|
32
|
+
name: 'CELO',
|
|
33
|
+
};
|
|
34
|
+
exports.AVAX = {
|
|
35
|
+
symbol: 'AVAX',
|
|
36
|
+
hash: '-',
|
|
37
|
+
decimals: 18,
|
|
38
|
+
name: 'AVAX',
|
|
39
|
+
};
|
|
40
|
+
exports.CRO = {
|
|
41
|
+
symbol: 'CRO',
|
|
42
|
+
hash: '-',
|
|
43
|
+
decimals: 18,
|
|
44
|
+
name: 'CRO',
|
|
45
|
+
};
|
|
46
|
+
exports.GAS = {
|
|
47
|
+
symbol: 'GAS',
|
|
48
|
+
hash: '-',
|
|
49
|
+
decimals: 18,
|
|
50
|
+
name: 'GAS',
|
|
51
|
+
};
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type
|
|
3
|
-
export declare const TOKENS: Record<NetworkType, Token[]>;
|
|
4
|
-
export declare const NATIVE_ASSETS: {
|
|
5
|
-
symbol: string;
|
|
6
|
-
name: string;
|
|
7
|
-
hash: string;
|
|
8
|
-
decimals: number;
|
|
9
|
-
}[];
|
|
10
|
-
export declare const BITQUERY_MIRROR_URL = "https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/";
|
|
11
|
-
export declare const BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, BitqueryNetwork>;
|
|
12
|
-
export declare const GHOSTMARKET_URL_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
|
|
13
|
-
export declare const GHOSTMARKET_CHAIN_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
|
|
1
|
+
import { Token } from '@cityofzion/blockchain-service';
|
|
2
|
+
export type AvailableNetworkIds = '1' | '10' | '25' | '56' | '137' | '250' | '1101' | '8453' | '80002' | '42161' | '42220' | '43114' | '59144' | '11155111' | '12227331';
|
|
14
3
|
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>;
|
|
17
4
|
export declare const DEFAULT_PATH = "44'/60'/0'/0/0";
|
|
5
|
+
export declare const NATIVE_ASSET_BY_NETWORK_ID: Record<AvailableNetworkIds, Token>;
|
|
6
|
+
export declare const RPC_LIST_BY_NETWORK_ID: Record<AvailableNetworkIds, string[]>;
|
|
7
|
+
export declare const DEFAULT_URL_BY_NETWORK_ID: Record<AvailableNetworkIds, string>;
|
|
8
|
+
export declare const NETWORK_NAME_BY_NETWORK_ID: Record<AvailableNetworkIds, string>;
|
|
9
|
+
export declare const BITQUERY_MIRROR_URL = "https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/";
|
|
10
|
+
export declare const BITQUERY_MIRROR_NETWORK_BY_NETWORK_ID: Partial<Record<AvailableNetworkIds, string>>;
|
|
11
|
+
export declare const GHOSTMARKET_URL_BY_NETWORK_TYPE: Partial<Record<AvailableNetworkIds, string>>;
|
|
12
|
+
export declare const GHOSTMARKET_CHAIN_BY_NETWORK_TYPE: Partial<Record<AvailableNetworkIds, string>>;
|
package/dist/constants.js
CHANGED
|
@@ -1,40 +1,104 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
8
|
-
exports.TOKENS = {
|
|
9
|
-
mainnet: [...common_json_1.default],
|
|
10
|
-
testnet: common_json_1.default,
|
|
11
|
-
custom: common_json_1.default,
|
|
12
|
-
};
|
|
13
|
-
exports.NATIVE_ASSETS = common_json_1.default;
|
|
14
|
-
exports.BITQUERY_MIRROR_URL = 'https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/';
|
|
15
|
-
exports.BITQUERY_MIRROR_NETWORK_BY_NETWORK_TYPE = {
|
|
16
|
-
mainnet: 'ethereum',
|
|
17
|
-
testnet: 'goerli',
|
|
18
|
-
};
|
|
19
|
-
exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = {
|
|
20
|
-
mainnet: 'https://api.ghostmarket.io/api/v2',
|
|
21
|
-
testnet: 'https://api-testnet.ghostmarket.io/api/v2',
|
|
22
|
-
};
|
|
23
|
-
exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = {
|
|
24
|
-
mainnet: 'eth',
|
|
25
|
-
testnet: 'etht',
|
|
26
|
-
};
|
|
3
|
+
exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = exports.BITQUERY_MIRROR_NETWORK_BY_NETWORK_ID = exports.BITQUERY_MIRROR_URL = exports.NETWORK_NAME_BY_NETWORK_ID = exports.DEFAULT_URL_BY_NETWORK_ID = exports.RPC_LIST_BY_NETWORK_ID = exports.NATIVE_ASSET_BY_NETWORK_ID = exports.DEFAULT_PATH = exports.DERIVATION_PATH = void 0;
|
|
4
|
+
const tokens_1 = require("./assets/tokens");
|
|
27
5
|
exports.DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
28
|
-
exports.
|
|
29
|
-
|
|
30
|
-
|
|
6
|
+
exports.DEFAULT_PATH = "44'/60'/0'/0/0";
|
|
7
|
+
exports.NATIVE_ASSET_BY_NETWORK_ID = {
|
|
8
|
+
'1': tokens_1.ETH,
|
|
9
|
+
'10': tokens_1.ETH,
|
|
10
|
+
'25': tokens_1.CRO,
|
|
11
|
+
'56': tokens_1.BNB,
|
|
12
|
+
'137': tokens_1.MATIC,
|
|
13
|
+
'1101': tokens_1.ETH,
|
|
14
|
+
'250': tokens_1.FTM,
|
|
15
|
+
'8453': tokens_1.ETH,
|
|
16
|
+
'80002': tokens_1.MATIC,
|
|
17
|
+
'42161': tokens_1.ETH,
|
|
18
|
+
'42220': tokens_1.CELO,
|
|
19
|
+
'43114': tokens_1.AVAX,
|
|
20
|
+
'59144': tokens_1.ETH,
|
|
21
|
+
'11155111': tokens_1.ETH,
|
|
22
|
+
'12227331': tokens_1.GAS,
|
|
23
|
+
};
|
|
24
|
+
exports.RPC_LIST_BY_NETWORK_ID = {
|
|
25
|
+
'1': [
|
|
31
26
|
'https://eth.llamarpc.com',
|
|
27
|
+
'https://mainnet.infura.io/v3/',
|
|
32
28
|
'https://ethereum-rpc.publicnode.com',
|
|
33
29
|
'https://endpoints.omniatech.io/v1/eth/mainnet/public',
|
|
34
30
|
'https://rpc.flashbots.net',
|
|
35
31
|
'https://rpc.mevblocker.io',
|
|
36
32
|
],
|
|
37
|
-
|
|
33
|
+
'10': [
|
|
34
|
+
'https://optimism.llamarpc.com',
|
|
35
|
+
'https://endpoints.omniatech.io/v1/op/mainnet/public',
|
|
36
|
+
'https://optimism-rpc.publicnode.com',
|
|
37
|
+
'https://optimism.meowrpc.com',
|
|
38
|
+
'https://optimism.rpc.subquery.network/public',
|
|
39
|
+
],
|
|
40
|
+
'25': ['https://cronos-evm-rpc.publicnode.com', 'https://1rpc.io/cro', 'https://rpc.vvs.finance'],
|
|
41
|
+
'56': [
|
|
42
|
+
'https://bsc-dataseed.binance.org/',
|
|
43
|
+
'https://binance.llamarpc.com',
|
|
44
|
+
'https://bsc-dataseed.bnbchain.org',
|
|
45
|
+
'https://endpoints.omniatech.io/v1/bsc/mainnet/public',
|
|
46
|
+
'https://bsc-rpc.publicnode.com',
|
|
47
|
+
],
|
|
48
|
+
'137': [
|
|
49
|
+
'https://polygon-mainnet.infura.io',
|
|
50
|
+
'https://polygon.llamarpc.com',
|
|
51
|
+
'https://endpoints.omniatech.io/v1/matic/mainnet/public',
|
|
52
|
+
'https://polygon.drpc.org',
|
|
53
|
+
'https://polygon.meowrpc.com',
|
|
54
|
+
],
|
|
55
|
+
'250': [
|
|
56
|
+
'https://endpoints.omniatech.io/v1/fantom/mainnet/public',
|
|
57
|
+
'https://rpcapi.fantom.network',
|
|
58
|
+
'https://fantom-pokt.nodies.app',
|
|
59
|
+
'https://fantom-rpc.publicnode.com',
|
|
60
|
+
'https://fantom.drpc.org',
|
|
61
|
+
],
|
|
62
|
+
'1101': [
|
|
63
|
+
'https://polygon-zkevm.drpc.org',
|
|
64
|
+
'https://polygon-zkevm.blockpi.network/v1/rpc/public',
|
|
65
|
+
'https://1rpc.io/polygon/zkevm',
|
|
66
|
+
],
|
|
67
|
+
'80002': [
|
|
68
|
+
'https://polygon-amoy.drpc.org',
|
|
69
|
+
'https://rpc.ankr.com/polygon_amoy',
|
|
70
|
+
'https://polygon-amoy-bor-rpc.publicnode.com',
|
|
71
|
+
],
|
|
72
|
+
'8453': [
|
|
73
|
+
'https://base.rpc.subquery.network/public',
|
|
74
|
+
'https://base.llamarpc.com',
|
|
75
|
+
'https://mainnet.base.org',
|
|
76
|
+
'https://1rpc.io/base',
|
|
77
|
+
'https://base.meowrpc.com',
|
|
78
|
+
'https://base-rpc.publicnode.com',
|
|
79
|
+
'https://endpoints.omniatech.io/v1/base/mainnet/public',
|
|
80
|
+
],
|
|
81
|
+
'42161': [
|
|
82
|
+
'https://arbitrum.llamarpc.com',
|
|
83
|
+
'https://arbitrum-one-rpc.publicnode.com',
|
|
84
|
+
'https://arb-mainnet-public.unifra.io',
|
|
85
|
+
'https://arbitrum-one.publicnode.com',
|
|
86
|
+
],
|
|
87
|
+
'42220': [
|
|
88
|
+
'https://forno.celo.org',
|
|
89
|
+
'https://api.tatum.io/v3/blockchain/node/celo-mainnet',
|
|
90
|
+
'https://rpc.ankr.com/celo',
|
|
91
|
+
],
|
|
92
|
+
'43114': [
|
|
93
|
+
'https://avalanche-mainnet.infura.io',
|
|
94
|
+
'https://avalanche-c-chain-rpc.publicnode.com',
|
|
95
|
+
'https://avalanche.public-rpc.com',
|
|
96
|
+
'https://endpoints.omniatech.io/v1/avax/mainnet/public',
|
|
97
|
+
'https://avalanche.drpc.org',
|
|
98
|
+
],
|
|
99
|
+
'59144': ['https://linea.decubate.com', 'https://linea.blockpi.network/v1/rpc/public', 'https://linea.decubate.com'],
|
|
100
|
+
'11155111': [
|
|
101
|
+
'https://ethereum-sepolia.rpc.subquery.network/public',
|
|
38
102
|
'https://ethereum-sepolia-rpc.publicnode.com',
|
|
39
103
|
'https://endpoints.omniatech.io/v1/eth/sepolia/public',
|
|
40
104
|
'https://eth-sepolia.public.blastapi.io',
|
|
@@ -42,11 +106,55 @@ exports.RPC_LIST_BY_NETWORK_TYPE = {
|
|
|
42
106
|
'https://1rpc.io/sepolia',
|
|
43
107
|
'https://eth-sepolia.api.onfinality.io/public',
|
|
44
108
|
],
|
|
45
|
-
|
|
109
|
+
'12227331': ['https://neoxseed1.ngd.network'],
|
|
46
110
|
};
|
|
47
|
-
exports.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
111
|
+
exports.DEFAULT_URL_BY_NETWORK_ID = {
|
|
112
|
+
'1': exports.RPC_LIST_BY_NETWORK_ID['1'][0],
|
|
113
|
+
'10': exports.RPC_LIST_BY_NETWORK_ID['10'][0],
|
|
114
|
+
'25': exports.RPC_LIST_BY_NETWORK_ID['25'][0],
|
|
115
|
+
'56': exports.RPC_LIST_BY_NETWORK_ID['56'][0],
|
|
116
|
+
'137': exports.RPC_LIST_BY_NETWORK_ID['137'][0],
|
|
117
|
+
'250': exports.RPC_LIST_BY_NETWORK_ID['250'][0],
|
|
118
|
+
'1101': exports.RPC_LIST_BY_NETWORK_ID['1101'][0],
|
|
119
|
+
'8453': exports.RPC_LIST_BY_NETWORK_ID['8453'][0],
|
|
120
|
+
'80002': exports.RPC_LIST_BY_NETWORK_ID['80002'][0],
|
|
121
|
+
'42161': exports.RPC_LIST_BY_NETWORK_ID['42161'][0],
|
|
122
|
+
'42220': exports.RPC_LIST_BY_NETWORK_ID['42220'][0],
|
|
123
|
+
'43114': exports.RPC_LIST_BY_NETWORK_ID['43114'][0],
|
|
124
|
+
'59144': exports.RPC_LIST_BY_NETWORK_ID['59144'][0],
|
|
125
|
+
'11155111': exports.RPC_LIST_BY_NETWORK_ID['11155111'][0],
|
|
126
|
+
'12227331': exports.RPC_LIST_BY_NETWORK_ID['12227331'][0],
|
|
127
|
+
};
|
|
128
|
+
exports.NETWORK_NAME_BY_NETWORK_ID = {
|
|
129
|
+
'1': 'Ethereum Mainnet',
|
|
130
|
+
'10': 'Optimism Mainnet',
|
|
131
|
+
'25': 'Cronos Mainnet',
|
|
132
|
+
'56': 'Binance Smart Chain Mainnet',
|
|
133
|
+
'137': 'Polygon Mainnet',
|
|
134
|
+
'250': 'Fantom Opera',
|
|
135
|
+
'1101': 'Polygon zkEVM',
|
|
136
|
+
'8453': 'Base',
|
|
137
|
+
'80002': 'Polygon Amoy',
|
|
138
|
+
'42161': 'Arbitrum One',
|
|
139
|
+
'42220': 'Celo Mainnet',
|
|
140
|
+
'43114': 'Avalanche C-Chain',
|
|
141
|
+
'59144': 'Linea',
|
|
142
|
+
'11155111': 'Ethereum Sepolia',
|
|
143
|
+
'12227331': 'NeoX Testnet',
|
|
144
|
+
};
|
|
145
|
+
exports.BITQUERY_MIRROR_URL = 'https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/';
|
|
146
|
+
exports.BITQUERY_MIRROR_NETWORK_BY_NETWORK_ID = {
|
|
147
|
+
'1': 'ethereum',
|
|
148
|
+
'25': 'cronos',
|
|
149
|
+
'56': 'bsc',
|
|
150
|
+
'137': 'matic',
|
|
151
|
+
'250': 'fantom',
|
|
152
|
+
'42220': 'celo_mainnet',
|
|
153
|
+
'43114': 'avalanche',
|
|
154
|
+
};
|
|
155
|
+
exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = {
|
|
156
|
+
1: 'https://api.ghostmarket.io/api/v2',
|
|
157
|
+
};
|
|
158
|
+
exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = {
|
|
159
|
+
1: 'eth',
|
|
51
160
|
};
|
|
52
|
-
exports.DEFAULT_PATH = "44'/60'/0'/0/0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"@ethersproject/json-wallets": "5.7.0",
|
|
19
19
|
"@ethersproject/bytes": "5.7.0",
|
|
20
20
|
"@ethersproject/bignumber": "5.7.0",
|
|
21
|
-
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
22
21
|
"@ledgerhq/hw-transport": "~6.30.5",
|
|
23
22
|
"@ledgerhq/hw-app-eth": "~6.35.7",
|
|
24
23
|
"@ethersproject/abstract-signer": "~5.7.0",
|
|
25
24
|
"@ethersproject/properties": "~5.7.0",
|
|
26
|
-
"@cityofzion/blockchain-service": "0.
|
|
25
|
+
"@cityofzion/blockchain-service": "1.0.0"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
28
|
+
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
29
29
|
"@types/jest": "29.5.3",
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
|
31
31
|
"@typescript-eslint/parser": "^6.5.0",
|