@cityofzion/bs-ethereum 2.0.0 → 2.0.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 +8 -7
- package/dist/BSEthereum.js +25 -19
- package/dist/BSEthereumHelper.d.ts +22 -0
- package/dist/BSEthereumHelper.js +236 -0
- package/dist/BitqueryBDSEthereum.d.ts +4 -1
- package/dist/BitqueryBDSEthereum.js +31 -11
- package/dist/BitqueryEDSEthereum.d.ts +3 -3
- package/dist/BitqueryEDSEthereum.js +10 -9
- package/dist/{LedgerServiceEthereum.d.ts → EthersLedgerServiceEthereum.d.ts} +4 -4
- package/dist/{LedgerServiceEthereum.js → EthersLedgerServiceEthereum.js} +39 -39
- package/dist/GhostMarketNDSEthereum.d.ts +5 -1
- package/dist/GhostMarketNDSEthereum.js +15 -7
- package/dist/RpcBDSEthereum.d.ts +1 -1
- package/dist/RpcBDSEthereum.js +8 -6
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -3
- package/package.json +2 -2
- package/dist/assets/tokens/index.d.ts +0 -9
- package/dist/assets/tokens/index.js +0 -51
- package/dist/constants.d.ts +0 -12
- package/dist/constants.js +0 -160
package/dist/BSEthereum.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { Account, AccountWithDerivationPath, BSCalculableFee, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, Network, NftDataService,
|
|
2
|
-
import {
|
|
1
|
+
import { Account, AccountWithDerivationPath, BSCalculableFee, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, Network, NftDataService, Token, TransferParam } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { EthersLedgerServiceEthereum } from './EthersLedgerServiceEthereum';
|
|
3
3
|
import Transport from '@ledgerhq/hw-transport';
|
|
4
|
-
import { AvailableNetworkIds } from './
|
|
4
|
+
import { AvailableNetworkIds } from './BSEthereumHelper';
|
|
5
5
|
export declare class BSEthereum<BSCustomName extends string = string> implements BlockchainService<BSCustomName, AvailableNetworkIds>, BSWithNft, BSWithNameService, BSCalculableFee, BSWithLedger {
|
|
6
|
+
#private;
|
|
6
7
|
readonly blockchainName: BSCustomName;
|
|
7
|
-
readonly feeToken: Token;
|
|
8
8
|
readonly derivationPath: string;
|
|
9
|
+
feeToken: Token;
|
|
9
10
|
blockchainDataService: BlockchainDataService;
|
|
10
11
|
exchangeDataService: ExchangeDataService;
|
|
11
|
-
ledgerService:
|
|
12
|
+
ledgerService: EthersLedgerServiceEthereum;
|
|
12
13
|
tokens: Token[];
|
|
13
14
|
nftDataService: NftDataService;
|
|
14
15
|
network: Network<AvailableNetworkIds>;
|
|
15
|
-
constructor(blockchainName: BSCustomName, network
|
|
16
|
-
setNetwork(
|
|
16
|
+
constructor(blockchainName: BSCustomName, network?: Network<AvailableNetworkIds>, getLedgerTransport?: (account: Account) => Promise<Transport>);
|
|
17
|
+
setNetwork(network: Network<AvailableNetworkIds>): void;
|
|
17
18
|
validateAddress(address: string): boolean;
|
|
18
19
|
validateEncrypted(json: string): boolean;
|
|
19
20
|
validateKey(key: string): boolean;
|
package/dist/BSEthereum.js
CHANGED
|
@@ -31,6 +31,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
35
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
38
|
+
};
|
|
39
|
+
var _BSEthereum_instances, _BSEthereum_setTokens;
|
|
34
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
41
|
exports.BSEthereum = void 0;
|
|
36
42
|
const ethers_1 = require("ethers");
|
|
@@ -41,28 +47,23 @@ const BitqueryEDSEthereum_1 = require("./BitqueryEDSEthereum");
|
|
|
41
47
|
const GhostMarketNDSEthereum_1 = require("./GhostMarketNDSEthereum");
|
|
42
48
|
const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
43
49
|
const BitqueryBDSEthereum_1 = require("./BitqueryBDSEthereum");
|
|
44
|
-
const
|
|
45
|
-
const
|
|
50
|
+
const EthersLedgerServiceEthereum_1 = require("./EthersLedgerServiceEthereum");
|
|
51
|
+
const BSEthereumHelper_1 = require("./BSEthereumHelper");
|
|
46
52
|
class BSEthereum {
|
|
47
53
|
constructor(blockchainName, network, getLedgerTransport) {
|
|
54
|
+
_BSEthereum_instances.add(this);
|
|
55
|
+
network = network !== null && network !== void 0 ? network : BSEthereumHelper_1.BSEthereumHelper.DEFAULT_NETWORK;
|
|
48
56
|
this.blockchainName = blockchainName;
|
|
49
|
-
this.ledgerService = new
|
|
50
|
-
this.derivationPath =
|
|
51
|
-
this.tokens = [constants_1.NATIVE_ASSET_BY_NETWORK_ID[network.id]];
|
|
52
|
-
this.feeToken = constants_1.NATIVE_ASSET_BY_NETWORK_ID[network.id];
|
|
57
|
+
this.ledgerService = new EthersLedgerServiceEthereum_1.EthersLedgerServiceEthereum(getLedgerTransport);
|
|
58
|
+
this.derivationPath = BSEthereumHelper_1.BSEthereumHelper.DERIVATION_PATH;
|
|
53
59
|
this.setNetwork(network);
|
|
54
60
|
}
|
|
55
|
-
setNetwork(
|
|
56
|
-
|
|
57
|
-
const network = {
|
|
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],
|
|
61
|
-
};
|
|
61
|
+
setNetwork(network) {
|
|
62
|
+
__classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_setTokens).call(this, network);
|
|
62
63
|
this.network = network;
|
|
63
|
-
const bitqueryNetwork =
|
|
64
|
+
const bitqueryNetwork = BitqueryBDSEthereum_1.BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID[network.id];
|
|
64
65
|
this.blockchainDataService = bitqueryNetwork ? new BitqueryBDSEthereum_1.BitqueryBDSEthereum(network) : new RpcBDSEthereum_1.RpcBDSEthereum(network);
|
|
65
|
-
this.exchangeDataService = new BitqueryEDSEthereum_1.BitqueryEDSEthereum(network.
|
|
66
|
+
this.exchangeDataService = new BitqueryEDSEthereum_1.BitqueryEDSEthereum(network, this.tokens);
|
|
66
67
|
this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network);
|
|
67
68
|
}
|
|
68
69
|
validateAddress(address) {
|
|
@@ -143,7 +144,7 @@ class BSEthereum {
|
|
|
143
144
|
}
|
|
144
145
|
let signer;
|
|
145
146
|
if (ledgerTransport) {
|
|
146
|
-
signer = new
|
|
147
|
+
signer = new EthersLedgerServiceEthereum_1.EthersLedgerSigner(ledgerTransport, provider);
|
|
147
148
|
}
|
|
148
149
|
else {
|
|
149
150
|
signer = new ethers_1.ethers.Wallet(param.senderAccount.key, provider);
|
|
@@ -151,7 +152,7 @@ class BSEthereum {
|
|
|
151
152
|
const decimals = (_a = param.intent.tokenDecimals) !== null && _a !== void 0 ? _a : 18;
|
|
152
153
|
const amount = ethersBigNumber.parseFixed(param.intent.amount, decimals);
|
|
153
154
|
let transactionParams;
|
|
154
|
-
const isNative =
|
|
155
|
+
const isNative = this.feeToken.hash === param.intent.tokenHash;
|
|
155
156
|
if (isNative) {
|
|
156
157
|
transactionParams = {
|
|
157
158
|
to: param.intent.receiverAddress,
|
|
@@ -180,14 +181,14 @@ class BSEthereum {
|
|
|
180
181
|
}
|
|
181
182
|
let signer;
|
|
182
183
|
if (ledgerTransport) {
|
|
183
|
-
signer = new
|
|
184
|
+
signer = new EthersLedgerServiceEthereum_1.EthersLedgerSigner(ledgerTransport, provider);
|
|
184
185
|
}
|
|
185
186
|
else {
|
|
186
187
|
signer = new ethers_1.ethers.Wallet(param.senderAccount.key, provider);
|
|
187
188
|
}
|
|
188
189
|
const gasPrice = yield provider.getGasPrice();
|
|
189
190
|
let estimated;
|
|
190
|
-
const isNative =
|
|
191
|
+
const isNative = this.feeToken.hash === param.intent.tokenHash;
|
|
191
192
|
const decimals = (_a = param.intent.tokenDecimals) !== null && _a !== void 0 ? _a : 18;
|
|
192
193
|
const amount = ethersBigNumber.parseFixed(param.intent.amount, decimals);
|
|
193
194
|
if (!isNative) {
|
|
@@ -214,3 +215,8 @@ class BSEthereum {
|
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
exports.BSEthereum = BSEthereum;
|
|
218
|
+
_BSEthereum_instances = new WeakSet(), _BSEthereum_setTokens = function _BSEthereum_setTokens(network) {
|
|
219
|
+
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(network);
|
|
220
|
+
this.tokens = [nativeAsset];
|
|
221
|
+
this.feeToken = nativeAsset;
|
|
222
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Network } from '@cityofzion/blockchain-service';
|
|
2
|
+
export type AvailableNetworkIds = '1' | '10' | '25' | '56' | '137' | '250' | '1101' | '8453' | '80002' | '42161' | '42220' | '43114' | '59144' | '11155111' | '12227331' | (string & {});
|
|
3
|
+
export declare class BSEthereumHelper {
|
|
4
|
+
#private;
|
|
5
|
+
static DERIVATION_PATH: string;
|
|
6
|
+
static DEFAULT_PATH: string;
|
|
7
|
+
static MAINNET_NETWORK_IDS: AvailableNetworkIds[];
|
|
8
|
+
static TESTNET_NETWORK_IDS: AvailableNetworkIds[];
|
|
9
|
+
static ALL_NETWORK_IDS: AvailableNetworkIds[];
|
|
10
|
+
static MAINNET_NETWORKS: Network<AvailableNetworkIds>[];
|
|
11
|
+
static TESTNET_NETWORKS: Network<AvailableNetworkIds>[];
|
|
12
|
+
static ALL_NETWORKS: Network<AvailableNetworkIds>[];
|
|
13
|
+
static DEFAULT_NETWORK: Network<AvailableNetworkIds>;
|
|
14
|
+
static getNativeAsset(network: Network<AvailableNetworkIds>): {
|
|
15
|
+
symbol: string;
|
|
16
|
+
name: string;
|
|
17
|
+
hash: string;
|
|
18
|
+
decimals: number;
|
|
19
|
+
};
|
|
20
|
+
static getNativeSymbol(network: Network<AvailableNetworkIds>): string;
|
|
21
|
+
static getRpcList(network: Network<AvailableNetworkIds>): string[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
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");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _a, _BSEthereumHelper_NATIVE_ASSET, _BSEthereumHelper_NATIVE_SYMBOL_BY_NETWORK_ID, _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BSEthereumHelper = void 0;
|
|
10
|
+
class BSEthereumHelper {
|
|
11
|
+
static getNativeAsset(network) {
|
|
12
|
+
return Object.assign(Object.assign({}, __classPrivateFieldGet(this, _a, "f", _BSEthereumHelper_NATIVE_ASSET)), { symbol: this.getNativeSymbol(network) });
|
|
13
|
+
}
|
|
14
|
+
static getNativeSymbol(network) {
|
|
15
|
+
var _b;
|
|
16
|
+
return (_b = __classPrivateFieldGet(this, _a, "f", _BSEthereumHelper_NATIVE_SYMBOL_BY_NETWORK_ID)[network.id]) !== null && _b !== void 0 ? _b : 'ETH';
|
|
17
|
+
}
|
|
18
|
+
static getRpcList(network) {
|
|
19
|
+
var _b;
|
|
20
|
+
return (_b = __classPrivateFieldGet(this, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)[network.id]) !== null && _b !== void 0 ? _b : [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.BSEthereumHelper = BSEthereumHelper;
|
|
24
|
+
_a = BSEthereumHelper;
|
|
25
|
+
_BSEthereumHelper_NATIVE_ASSET = { value: {
|
|
26
|
+
decimals: 18,
|
|
27
|
+
hash: '-',
|
|
28
|
+
name: 'ETH',
|
|
29
|
+
symbol: 'ETH',
|
|
30
|
+
} };
|
|
31
|
+
_BSEthereumHelper_NATIVE_SYMBOL_BY_NETWORK_ID = { value: {
|
|
32
|
+
'1': 'ETH',
|
|
33
|
+
'10': 'ETH',
|
|
34
|
+
'25': 'CRO',
|
|
35
|
+
'56': 'BNB',
|
|
36
|
+
'137': 'MATIC',
|
|
37
|
+
'1101': 'ETH',
|
|
38
|
+
'250': 'FTM',
|
|
39
|
+
'8453': 'ETH',
|
|
40
|
+
'80002': 'MATIC',
|
|
41
|
+
'42161': 'ETH',
|
|
42
|
+
'42220': 'CELO',
|
|
43
|
+
'43114': 'AVAX',
|
|
44
|
+
'59144': 'ETH',
|
|
45
|
+
'11155111': 'ETH',
|
|
46
|
+
'12227331': 'GAS',
|
|
47
|
+
} };
|
|
48
|
+
_BSEthereumHelper_RPC_LIST_BY_NETWORK_ID = { value: {
|
|
49
|
+
'1': [
|
|
50
|
+
'https://eth.llamarpc.com',
|
|
51
|
+
'https://mainnet.infura.io/v3/',
|
|
52
|
+
'https://ethereum-rpc.publicnode.com',
|
|
53
|
+
'https://endpoints.omniatech.io/v1/eth/mainnet/public',
|
|
54
|
+
'https://rpc.flashbots.net',
|
|
55
|
+
'https://rpc.mevblocker.io',
|
|
56
|
+
],
|
|
57
|
+
'10': [
|
|
58
|
+
'https://optimism.llamarpc.com',
|
|
59
|
+
'https://endpoints.omniatech.io/v1/op/mainnet/public',
|
|
60
|
+
'https://optimism-rpc.publicnode.com',
|
|
61
|
+
'https://optimism.meowrpc.com',
|
|
62
|
+
'https://optimism.rpc.subquery.network/public',
|
|
63
|
+
],
|
|
64
|
+
'25': ['https://cronos-evm-rpc.publicnode.com', 'https://1rpc.io/cro', 'https://rpc.vvs.finance'],
|
|
65
|
+
'56': [
|
|
66
|
+
'https://bsc-dataseed.binance.org/',
|
|
67
|
+
'https://binance.llamarpc.com',
|
|
68
|
+
'https://bsc-dataseed.bnbchain.org',
|
|
69
|
+
'https://endpoints.omniatech.io/v1/bsc/mainnet/public',
|
|
70
|
+
'https://bsc-rpc.publicnode.com',
|
|
71
|
+
],
|
|
72
|
+
'137': [
|
|
73
|
+
'https://polygon-mainnet.infura.io',
|
|
74
|
+
'https://polygon.llamarpc.com',
|
|
75
|
+
'https://endpoints.omniatech.io/v1/matic/mainnet/public',
|
|
76
|
+
'https://polygon.drpc.org',
|
|
77
|
+
'https://polygon.meowrpc.com',
|
|
78
|
+
],
|
|
79
|
+
'250': [
|
|
80
|
+
'https://endpoints.omniatech.io/v1/fantom/mainnet/public',
|
|
81
|
+
'https://rpcapi.fantom.network',
|
|
82
|
+
'https://fantom-pokt.nodies.app',
|
|
83
|
+
'https://fantom-rpc.publicnode.com',
|
|
84
|
+
'https://fantom.drpc.org',
|
|
85
|
+
],
|
|
86
|
+
'1101': [
|
|
87
|
+
'https://polygon-zkevm.drpc.org',
|
|
88
|
+
'https://polygon-zkevm.blockpi.network/v1/rpc/public',
|
|
89
|
+
'https://1rpc.io/polygon/zkevm',
|
|
90
|
+
],
|
|
91
|
+
'80002': [
|
|
92
|
+
'https://polygon-amoy.drpc.org',
|
|
93
|
+
'https://rpc.ankr.com/polygon_amoy',
|
|
94
|
+
'https://polygon-amoy-bor-rpc.publicnode.com',
|
|
95
|
+
],
|
|
96
|
+
'8453': [
|
|
97
|
+
'https://base.rpc.subquery.network/public',
|
|
98
|
+
'https://base.llamarpc.com',
|
|
99
|
+
'https://mainnet.base.org',
|
|
100
|
+
'https://1rpc.io/base',
|
|
101
|
+
'https://base.meowrpc.com',
|
|
102
|
+
'https://base-rpc.publicnode.com',
|
|
103
|
+
'https://endpoints.omniatech.io/v1/base/mainnet/public',
|
|
104
|
+
],
|
|
105
|
+
'42161': [
|
|
106
|
+
'https://arbitrum.llamarpc.com',
|
|
107
|
+
'https://arbitrum-one-rpc.publicnode.com',
|
|
108
|
+
'https://arb-mainnet-public.unifra.io',
|
|
109
|
+
'https://arbitrum-one.publicnode.com',
|
|
110
|
+
],
|
|
111
|
+
'42220': [
|
|
112
|
+
'https://forno.celo.org',
|
|
113
|
+
'https://api.tatum.io/v3/blockchain/node/celo-mainnet',
|
|
114
|
+
'https://rpc.ankr.com/celo',
|
|
115
|
+
],
|
|
116
|
+
'43114': [
|
|
117
|
+
'https://avalanche-mainnet.infura.io',
|
|
118
|
+
'https://avalanche-c-chain-rpc.publicnode.com',
|
|
119
|
+
'https://avalanche.public-rpc.com',
|
|
120
|
+
'https://endpoints.omniatech.io/v1/avax/mainnet/public',
|
|
121
|
+
'https://avalanche.drpc.org',
|
|
122
|
+
],
|
|
123
|
+
'59144': [
|
|
124
|
+
'https://linea.decubate.com',
|
|
125
|
+
'https://linea.blockpi.network/v1/rpc/public',
|
|
126
|
+
'https://linea.decubate.com',
|
|
127
|
+
],
|
|
128
|
+
'11155111': [
|
|
129
|
+
'https://ethereum-sepolia.rpc.subquery.network/public',
|
|
130
|
+
'https://ethereum-sepolia-rpc.publicnode.com',
|
|
131
|
+
'https://endpoints.omniatech.io/v1/eth/sepolia/public',
|
|
132
|
+
'https://eth-sepolia.public.blastapi.io',
|
|
133
|
+
'https://eth-sepolia-public.unifra.io',
|
|
134
|
+
'https://1rpc.io/sepolia',
|
|
135
|
+
'https://eth-sepolia.api.onfinality.io/public',
|
|
136
|
+
],
|
|
137
|
+
'12227331': ['https://neoxseed1.ngd.network'],
|
|
138
|
+
} };
|
|
139
|
+
BSEthereumHelper.DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
140
|
+
BSEthereumHelper.DEFAULT_PATH = "44'/60'/0'/0/0";
|
|
141
|
+
BSEthereumHelper.MAINNET_NETWORK_IDS = [
|
|
142
|
+
'1',
|
|
143
|
+
'10',
|
|
144
|
+
'25',
|
|
145
|
+
'56',
|
|
146
|
+
'137',
|
|
147
|
+
'250',
|
|
148
|
+
'8453',
|
|
149
|
+
'42161',
|
|
150
|
+
'42220',
|
|
151
|
+
'43114',
|
|
152
|
+
'59144',
|
|
153
|
+
];
|
|
154
|
+
BSEthereumHelper.TESTNET_NETWORK_IDS = ['1101', '80002', '11155111', '12227331'];
|
|
155
|
+
BSEthereumHelper.ALL_NETWORK_IDS = [..._a.MAINNET_NETWORK_IDS, ..._a.TESTNET_NETWORK_IDS];
|
|
156
|
+
BSEthereumHelper.MAINNET_NETWORKS = [
|
|
157
|
+
{
|
|
158
|
+
id: '1',
|
|
159
|
+
name: 'Ethereum Mainnet',
|
|
160
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['1'][0],
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: '10',
|
|
164
|
+
name: 'Optimism Mainnet',
|
|
165
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['10'][0],
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: '25',
|
|
169
|
+
name: 'Cronos Mainnet',
|
|
170
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['25'][0],
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: '56',
|
|
174
|
+
name: 'Binance Smart Chain Mainnet',
|
|
175
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['56'][0],
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: '137',
|
|
179
|
+
name: 'Polygon Mainnet',
|
|
180
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['137'][0],
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: '250',
|
|
184
|
+
name: 'Fantom Mainnet',
|
|
185
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['250'][0],
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: '8453',
|
|
189
|
+
name: 'Base Protocol Mainnet',
|
|
190
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['8453'][0],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: '42161',
|
|
194
|
+
name: 'Arbitrum Mainnet',
|
|
195
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['42161'][0],
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: '42220',
|
|
199
|
+
name: 'Celo Mainnet',
|
|
200
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['42220'][0],
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
id: '43114',
|
|
204
|
+
name: 'Avalanche Mainnet',
|
|
205
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['43114'][0],
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: '59144',
|
|
209
|
+
name: 'Linea Mainnet',
|
|
210
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['59144'][0],
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
BSEthereumHelper.TESTNET_NETWORKS = [
|
|
214
|
+
{
|
|
215
|
+
id: '1101',
|
|
216
|
+
name: 'Polygon zkEVM Testnet',
|
|
217
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['1101'][0],
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: '80002',
|
|
221
|
+
name: 'Polygon Testnet',
|
|
222
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['80002'][0],
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: '11155111',
|
|
226
|
+
name: 'Ethereum Sepolia Testnet',
|
|
227
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['11155111'][0],
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: '12227331',
|
|
231
|
+
name: 'Neo3 Testnet',
|
|
232
|
+
url: __classPrivateFieldGet(_a, _a, "f", _BSEthereumHelper_RPC_LIST_BY_NETWORK_ID)['12227331'][0],
|
|
233
|
+
},
|
|
234
|
+
];
|
|
235
|
+
BSEthereumHelper.ALL_NETWORKS = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
|
|
236
|
+
BSEthereumHelper.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { BalanceResponse, ContractResponse, Token, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, Network } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { AvailableNetworkIds } from './constants';
|
|
3
2
|
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
3
|
+
import { AvailableNetworkIds } from './BSEthereumHelper';
|
|
4
4
|
export declare class BitqueryBDSEthereum extends RpcBDSEthereum {
|
|
5
5
|
#private;
|
|
6
|
+
static MIRROR_URL: string;
|
|
7
|
+
static MIRROR_NETWORK_BY_NETWORK_ID: Partial<Record<AvailableNetworkIds, string>>;
|
|
8
|
+
static getMirrorNetworkId(network: Network<AvailableNetworkIds>): string;
|
|
6
9
|
maxTimeToConfirmTransactionInMs: number;
|
|
7
10
|
constructor(network: Network<AvailableNetworkIds>);
|
|
8
11
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
@@ -22,28 +22,35 @@ 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_network, _BitqueryBDSEthereum_tokenCache;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.BitqueryBDSEthereum = void 0;
|
|
28
|
-
const constants_1 = require("./constants");
|
|
29
28
|
const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
30
29
|
const axios_1 = __importDefault(require("axios"));
|
|
30
|
+
const BSEthereumHelper_1 = require("./BSEthereumHelper");
|
|
31
31
|
class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
32
|
+
static getMirrorNetworkId(network) {
|
|
33
|
+
const mirrorNetwork = BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID[network.id];
|
|
34
|
+
if (!mirrorNetwork)
|
|
35
|
+
throw new Error('Mirror network is not supported');
|
|
36
|
+
return mirrorNetwork;
|
|
37
|
+
}
|
|
32
38
|
constructor(network) {
|
|
33
39
|
super(network);
|
|
34
40
|
_BitqueryBDSEthereum_client.set(this, void 0);
|
|
35
|
-
|
|
41
|
+
_BitqueryBDSEthereum_network.set(this, void 0);
|
|
36
42
|
_BitqueryBDSEthereum_tokenCache.set(this, new Map());
|
|
37
43
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 8;
|
|
38
|
-
__classPrivateFieldSet(this,
|
|
44
|
+
__classPrivateFieldSet(this, _BitqueryBDSEthereum_network, network, "f");
|
|
39
45
|
__classPrivateFieldSet(this, _BitqueryBDSEthereum_client, axios_1.default.create({
|
|
40
|
-
baseURL:
|
|
46
|
+
baseURL: BitqueryBDSEthereum.MIRROR_URL,
|
|
41
47
|
}), "f");
|
|
42
48
|
}
|
|
43
49
|
getTransaction(hash) {
|
|
44
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const mirrorNetwork = BitqueryBDSEthereum.getMirrorNetworkId(__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f"));
|
|
45
52
|
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-transaction/${hash}`, {
|
|
46
|
-
params: { network:
|
|
53
|
+
params: { network: mirrorNetwork },
|
|
47
54
|
});
|
|
48
55
|
if (!result.data || !result.data.ethereum.transfers.length)
|
|
49
56
|
throw new Error('Transaction not found');
|
|
@@ -64,8 +71,9 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
64
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
72
|
const limit = 10;
|
|
66
73
|
const offset = limit * (page - 1);
|
|
74
|
+
const mirrorNetwork = BitqueryBDSEthereum.getMirrorNetworkId(__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f"));
|
|
67
75
|
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-transactions/${address}`, {
|
|
68
|
-
params: { network:
|
|
76
|
+
params: { network: mirrorNetwork, limit, offset },
|
|
69
77
|
});
|
|
70
78
|
if (!result.data)
|
|
71
79
|
throw new Error('Address does not have transactions');
|
|
@@ -105,8 +113,9 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
105
113
|
if (__classPrivateFieldGet(this, _BitqueryBDSEthereum_tokenCache, "f").has(hash)) {
|
|
106
114
|
return __classPrivateFieldGet(this, _BitqueryBDSEthereum_tokenCache, "f").get(hash);
|
|
107
115
|
}
|
|
116
|
+
const mirrorNetwork = BitqueryBDSEthereum.getMirrorNetworkId(__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f"));
|
|
108
117
|
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-token-info/${hash}`, {
|
|
109
|
-
params: { network:
|
|
118
|
+
params: { network: mirrorNetwork },
|
|
110
119
|
});
|
|
111
120
|
if (!result.data || result.data.ethereum.smartContractCalls.length <= 0)
|
|
112
121
|
throw new Error('Token not found');
|
|
@@ -126,12 +135,13 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
126
135
|
getBalance(address) {
|
|
127
136
|
var _a, _b, _c, _d;
|
|
128
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
const mirrorNetwork = BitqueryBDSEthereum.getMirrorNetworkId(__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f"));
|
|
129
139
|
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-balance/${address}`, {
|
|
130
|
-
params: { network:
|
|
140
|
+
params: { network: mirrorNetwork },
|
|
131
141
|
});
|
|
132
142
|
const data = (_b = (_a = result.data) === null || _a === void 0 ? void 0 : _a.ethereum.address[0].balances) !== null && _b !== void 0 ? _b : [];
|
|
133
143
|
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 =
|
|
144
|
+
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f"));
|
|
135
145
|
const balances = [
|
|
136
146
|
{
|
|
137
147
|
amount: nativeBalance.toString(),
|
|
@@ -180,4 +190,14 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
180
190
|
}
|
|
181
191
|
}
|
|
182
192
|
exports.BitqueryBDSEthereum = BitqueryBDSEthereum;
|
|
183
|
-
_BitqueryBDSEthereum_client = new WeakMap(),
|
|
193
|
+
_BitqueryBDSEthereum_client = new WeakMap(), _BitqueryBDSEthereum_network = new WeakMap(), _BitqueryBDSEthereum_tokenCache = new WeakMap();
|
|
194
|
+
BitqueryBDSEthereum.MIRROR_URL = 'https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/';
|
|
195
|
+
BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID = {
|
|
196
|
+
'1': 'ethereum',
|
|
197
|
+
'25': 'cronos',
|
|
198
|
+
'56': 'bsc',
|
|
199
|
+
'137': 'matic',
|
|
200
|
+
'250': 'fantom',
|
|
201
|
+
'42220': 'celo_mainnet',
|
|
202
|
+
'43114': 'avalanche',
|
|
203
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CryptoCompareEDS, Currency, ExchangeDataService, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { AvailableNetworkIds } from './
|
|
1
|
+
import { CryptoCompareEDS, Currency, ExchangeDataService, Network, Token, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './BSEthereumHelper';
|
|
3
3
|
export declare class BitqueryEDSEthereum extends CryptoCompareEDS implements ExchangeDataService {
|
|
4
4
|
#private;
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(network: Network<AvailableNetworkIds>, tokens: Token[]);
|
|
6
6
|
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
7
|
private getCurrencyRatio;
|
|
8
8
|
}
|
|
@@ -22,30 +22,31 @@ 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_network;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.BitqueryEDSEthereum = void 0;
|
|
28
28
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
29
29
|
const axios_1 = __importDefault(require("axios"));
|
|
30
30
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
31
31
|
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
32
|
-
const
|
|
32
|
+
const BitqueryBDSEthereum_1 = require("./BitqueryBDSEthereum");
|
|
33
33
|
dayjs_1.default.extend(utc_1.default);
|
|
34
34
|
class BitqueryEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
|
|
35
|
-
constructor(
|
|
36
|
-
super(
|
|
35
|
+
constructor(network, tokens) {
|
|
36
|
+
super(tokens);
|
|
37
37
|
_BitqueryEDSEthereum_client.set(this, void 0);
|
|
38
|
-
|
|
39
|
-
__classPrivateFieldSet(this,
|
|
38
|
+
_BitqueryEDSEthereum_network.set(this, void 0);
|
|
39
|
+
__classPrivateFieldSet(this, _BitqueryEDSEthereum_network, network, "f");
|
|
40
40
|
__classPrivateFieldSet(this, _BitqueryEDSEthereum_client, axios_1.default.create({
|
|
41
|
-
baseURL:
|
|
41
|
+
baseURL: BitqueryBDSEthereum_1.BitqueryBDSEthereum.MIRROR_URL,
|
|
42
42
|
}), "f");
|
|
43
43
|
}
|
|
44
44
|
getTokenPrices(currency) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
const twoDaysAgo = dayjs_1.default.utc().subtract(2, 'day').startOf('date').toISOString();
|
|
47
|
+
const mirrorNetwork = BitqueryBDSEthereum_1.BitqueryBDSEthereum.getMirrorNetworkId(__classPrivateFieldGet(this, _BitqueryEDSEthereum_network, "f"));
|
|
47
48
|
const result = yield __classPrivateFieldGet(this, _BitqueryEDSEthereum_client, "f").get(`/get-price`, {
|
|
48
|
-
params: { network:
|
|
49
|
+
params: { network: mirrorNetwork, after: twoDaysAgo },
|
|
49
50
|
});
|
|
50
51
|
if (!result.data) {
|
|
51
52
|
throw new Error('There is no price data');
|
|
@@ -70,4 +71,4 @@ class BitqueryEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
exports.BitqueryEDSEthereum = BitqueryEDSEthereum;
|
|
73
|
-
_BitqueryEDSEthereum_client = new WeakMap(),
|
|
74
|
+
_BitqueryEDSEthereum_client = new WeakMap(), _BitqueryEDSEthereum_network = new WeakMap();
|
|
@@ -2,21 +2,21 @@ import { Account, LedgerService, LedgerServiceEmitter } from '@cityofzion/blockc
|
|
|
2
2
|
import Transport from '@ledgerhq/hw-transport';
|
|
3
3
|
import { ethers, Signer } from 'ethers';
|
|
4
4
|
import { TypedDataSigner } from '@ethersproject/abstract-signer';
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class EthersLedgerSigner extends Signer implements TypedDataSigner {
|
|
6
6
|
#private;
|
|
7
7
|
constructor(transport: Transport, provider?: ethers.providers.Provider, emitter?: LedgerServiceEmitter);
|
|
8
|
-
connect(provider: ethers.providers.Provider):
|
|
8
|
+
connect(provider: ethers.providers.Provider): EthersLedgerSigner;
|
|
9
9
|
getAddress(): Promise<string>;
|
|
10
10
|
getPublicKey(): Promise<string>;
|
|
11
11
|
signMessage(message: string | ethers.utils.Bytes): Promise<string>;
|
|
12
12
|
signTransaction(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>): Promise<string>;
|
|
13
13
|
_signTypedData(domain: ethers.TypedDataDomain, types: Record<string, ethers.TypedDataField[]>, value: Record<string, any>): Promise<string>;
|
|
14
14
|
}
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class EthersLedgerServiceEthereum implements LedgerService {
|
|
16
16
|
getLedgerTransport?: ((account: Account) => Promise<Transport>) | undefined;
|
|
17
17
|
emitter: LedgerServiceEmitter;
|
|
18
18
|
constructor(getLedgerTransport?: ((account: Account) => Promise<Transport>) | undefined);
|
|
19
19
|
getAddress(transport: Transport): Promise<string>;
|
|
20
20
|
getPublicKey(transport: Transport): Promise<string>;
|
|
21
|
-
getSigner(transport: Transport):
|
|
21
|
+
getSigner(transport: Transport): EthersLedgerSigner;
|
|
22
22
|
}
|
|
@@ -45,40 +45,40 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
45
45
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
47
|
};
|
|
48
|
-
var
|
|
48
|
+
var _EthersLedgerSigner_instances, _EthersLedgerSigner_transport, _EthersLedgerSigner_emitter, _EthersLedgerSigner_path, _EthersLedgerSigner_retry;
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.
|
|
50
|
+
exports.EthersLedgerServiceEthereum = exports.EthersLedgerSigner = void 0;
|
|
51
51
|
const hw_app_eth_1 = __importStar(require("@ledgerhq/hw-app-eth"));
|
|
52
52
|
const ethers_1 = require("ethers");
|
|
53
53
|
const properties_1 = require("@ethersproject/properties");
|
|
54
|
-
const constants_1 = require("./constants");
|
|
55
54
|
const events_1 = __importDefault(require("events"));
|
|
56
|
-
|
|
55
|
+
const BSEthereumHelper_1 = require("./BSEthereumHelper");
|
|
56
|
+
class EthersLedgerSigner extends ethers_1.Signer {
|
|
57
57
|
constructor(transport, provider, emitter) {
|
|
58
58
|
super();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
__classPrivateFieldSet(this,
|
|
64
|
-
__classPrivateFieldSet(this,
|
|
65
|
-
__classPrivateFieldSet(this,
|
|
59
|
+
_EthersLedgerSigner_instances.add(this);
|
|
60
|
+
_EthersLedgerSigner_transport.set(this, void 0);
|
|
61
|
+
_EthersLedgerSigner_emitter.set(this, void 0);
|
|
62
|
+
_EthersLedgerSigner_path.set(this, void 0);
|
|
63
|
+
__classPrivateFieldSet(this, _EthersLedgerSigner_path, BSEthereumHelper_1.BSEthereumHelper.DEFAULT_PATH, "f");
|
|
64
|
+
__classPrivateFieldSet(this, _EthersLedgerSigner_transport, transport, "f");
|
|
65
|
+
__classPrivateFieldSet(this, _EthersLedgerSigner_emitter, emitter, "f");
|
|
66
66
|
(0, properties_1.defineReadOnly)(this, 'provider', provider);
|
|
67
67
|
}
|
|
68
68
|
connect(provider) {
|
|
69
|
-
return new
|
|
69
|
+
return new EthersLedgerSigner(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"), provider, __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f"));
|
|
70
70
|
}
|
|
71
71
|
getAddress() {
|
|
72
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
74
|
-
const { address } = yield __classPrivateFieldGet(this,
|
|
73
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
74
|
+
const { address } = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.getAddress(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f")));
|
|
75
75
|
return ethers_1.ethers.utils.getAddress(address);
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
getPublicKey() {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
81
|
-
const { publicKey } = yield __classPrivateFieldGet(this,
|
|
80
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
81
|
+
const { publicKey } = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.getAddress(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f")));
|
|
82
82
|
return '0x' + publicKey;
|
|
83
83
|
});
|
|
84
84
|
}
|
|
@@ -89,17 +89,17 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
89
89
|
if (typeof message === 'string') {
|
|
90
90
|
message = ethers_1.ethers.utils.toUtf8Bytes(message);
|
|
91
91
|
}
|
|
92
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
93
|
-
(_a = __classPrivateFieldGet(this,
|
|
94
|
-
const obj = yield __classPrivateFieldGet(this,
|
|
95
|
-
(_b = __classPrivateFieldGet(this,
|
|
92
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
93
|
+
(_a = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _a === void 0 ? void 0 : _a.emit('getSignatureStart');
|
|
94
|
+
const obj = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.signPersonalMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f"), ethers_1.ethers.utils.hexlify(message).substring(2)));
|
|
95
|
+
(_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
|
|
96
96
|
// Normalize the signature for Ethers
|
|
97
97
|
obj.r = '0x' + obj.r;
|
|
98
98
|
obj.s = '0x' + obj.s;
|
|
99
99
|
return ethers_1.ethers.utils.joinSignature(obj);
|
|
100
100
|
}
|
|
101
101
|
catch (error) {
|
|
102
|
-
(_c = __classPrivateFieldGet(this,
|
|
102
|
+
(_c = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _c === void 0 ? void 0 : _c.emit('getSignatureEnd');
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
});
|
|
@@ -108,7 +108,7 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
108
108
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
109
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
110
|
try {
|
|
111
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
111
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
112
112
|
const tx = yield ethers_1.ethers.utils.resolveProperties(transaction);
|
|
113
113
|
const unsignedTransaction = {
|
|
114
114
|
chainId: (_a = tx.chainId) !== null && _a !== void 0 ? _a : undefined,
|
|
@@ -121,9 +121,9 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
121
121
|
};
|
|
122
122
|
const serializedUnsignedTransaction = ethers_1.ethers.utils.serializeTransaction(unsignedTransaction).substring(2);
|
|
123
123
|
const resolution = yield hw_app_eth_1.ledgerService.resolveTransaction(serializedUnsignedTransaction, {}, {});
|
|
124
|
-
(_g = __classPrivateFieldGet(this,
|
|
125
|
-
const signature = yield __classPrivateFieldGet(this,
|
|
126
|
-
(_h = __classPrivateFieldGet(this,
|
|
124
|
+
(_g = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _g === void 0 ? void 0 : _g.emit('getSignatureStart');
|
|
125
|
+
const signature = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.signTransaction(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f"), serializedUnsignedTransaction, resolution));
|
|
126
|
+
(_h = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _h === void 0 ? void 0 : _h.emit('getSignatureEnd');
|
|
127
127
|
return ethers_1.ethers.utils.serializeTransaction(unsignedTransaction, {
|
|
128
128
|
v: ethers_1.ethers.BigNumber.from('0x' + signature.v).toNumber(),
|
|
129
129
|
r: '0x' + signature.r,
|
|
@@ -131,7 +131,7 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
catch (error) {
|
|
134
|
-
(_j = __classPrivateFieldGet(this,
|
|
134
|
+
(_j = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _j === void 0 ? void 0 : _j.emit('getSignatureEnd');
|
|
135
135
|
throw error;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
@@ -149,32 +149,32 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
149
149
|
return resolved;
|
|
150
150
|
}));
|
|
151
151
|
const payload = ethers_1.ethers.utils._TypedDataEncoder.getPayload(populated.domain, types, populated.value);
|
|
152
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
153
|
-
(_a = __classPrivateFieldGet(this,
|
|
152
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
153
|
+
(_a = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _a === void 0 ? void 0 : _a.emit('getSignatureStart');
|
|
154
154
|
let obj;
|
|
155
155
|
try {
|
|
156
|
-
obj = yield __classPrivateFieldGet(this,
|
|
156
|
+
obj = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.signEIP712Message(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f"), payload));
|
|
157
157
|
}
|
|
158
158
|
catch (_d) {
|
|
159
159
|
const domainSeparatorHex = ethers_1.ethers.utils._TypedDataEncoder.hashDomain(payload.domain);
|
|
160
160
|
const hashStructMessageHex = ethers_1.ethers.utils._TypedDataEncoder.hashStruct(payload.primaryType, types, payload.message);
|
|
161
|
-
obj = yield __classPrivateFieldGet(this,
|
|
161
|
+
obj = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.signEIP712HashedMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f"), domainSeparatorHex, hashStructMessageHex));
|
|
162
162
|
}
|
|
163
|
-
(_b = __classPrivateFieldGet(this,
|
|
163
|
+
(_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
|
|
164
164
|
// Normalize the signature for Ethers
|
|
165
165
|
obj.r = '0x' + obj.r;
|
|
166
166
|
obj.s = '0x' + obj.s;
|
|
167
167
|
return ethers_1.ethers.utils.joinSignature(obj);
|
|
168
168
|
}
|
|
169
169
|
catch (error) {
|
|
170
|
-
(_c = __classPrivateFieldGet(this,
|
|
170
|
+
(_c = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _c === void 0 ? void 0 : _c.emit('getSignatureEnd');
|
|
171
171
|
throw error;
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
exports.
|
|
177
|
-
|
|
176
|
+
exports.EthersLedgerSigner = EthersLedgerSigner;
|
|
177
|
+
_EthersLedgerSigner_transport = new WeakMap(), _EthersLedgerSigner_emitter = new WeakMap(), _EthersLedgerSigner_path = new WeakMap(), _EthersLedgerSigner_instances = new WeakSet(), _EthersLedgerSigner_retry = function _EthersLedgerSigner_retry(callback) {
|
|
178
178
|
// eslint-disable-next-line no-async-promise-executor
|
|
179
179
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
180
180
|
// Wait up to 5 seconds
|
|
@@ -193,28 +193,28 @@ _LedgerSigner_transport = new WeakMap(), _LedgerSigner_emitter = new WeakMap(),
|
|
|
193
193
|
return reject(new Error('timeout'));
|
|
194
194
|
}));
|
|
195
195
|
};
|
|
196
|
-
class
|
|
196
|
+
class EthersLedgerServiceEthereum {
|
|
197
197
|
constructor(getLedgerTransport) {
|
|
198
198
|
this.getLedgerTransport = getLedgerTransport;
|
|
199
199
|
this.emitter = new events_1.default();
|
|
200
200
|
}
|
|
201
201
|
getAddress(transport) {
|
|
202
202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
const signer = new
|
|
203
|
+
const signer = new EthersLedgerSigner(transport);
|
|
204
204
|
return yield signer.getAddress();
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
getPublicKey(transport) {
|
|
208
208
|
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
const signer = new
|
|
209
|
+
const signer = new EthersLedgerSigner(transport);
|
|
210
210
|
return yield signer.getPublicKey();
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
getSigner(transport) {
|
|
214
|
-
return new
|
|
214
|
+
return new EthersLedgerSigner(transport, undefined, this.emitter);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
exports.
|
|
217
|
+
exports.EthersLedgerServiceEthereum = EthersLedgerServiceEthereum;
|
|
218
218
|
function wait(duration) {
|
|
219
219
|
return new Promise(resolve => {
|
|
220
220
|
setTimeout(resolve, duration);
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { RpcNDSEthereum } from './RpcNDSEthereum';
|
|
3
|
-
import { AvailableNetworkIds } from './
|
|
3
|
+
import { AvailableNetworkIds } from './BSEthereumHelper';
|
|
4
4
|
export declare class GhostMarketNDSEthereum extends RpcNDSEthereum {
|
|
5
5
|
#private;
|
|
6
|
+
static CONFIG_BY_NETWORK_ID: Partial<Record<AvailableNetworkIds, {
|
|
7
|
+
url: string;
|
|
8
|
+
chain: string;
|
|
9
|
+
}>>;
|
|
6
10
|
constructor(network: Network<AvailableNetworkIds>);
|
|
7
11
|
getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
8
12
|
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
@@ -22,18 +22,17 @@ 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_network;
|
|
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
|
-
const constants_1 = require("./constants");
|
|
32
31
|
class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
33
32
|
constructor(network) {
|
|
34
33
|
super(network);
|
|
35
|
-
|
|
36
|
-
__classPrivateFieldSet(this,
|
|
34
|
+
_GhostMarketNDSEthereum_network.set(this, void 0);
|
|
35
|
+
__classPrivateFieldSet(this, _GhostMarketNDSEthereum_network, network, "f");
|
|
37
36
|
}
|
|
38
37
|
getNftsByAddress({ address, size = 18, cursor }) {
|
|
39
38
|
var _a;
|
|
@@ -69,8 +68,11 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
|
69
68
|
return srcImage;
|
|
70
69
|
}
|
|
71
70
|
getUrlWithParams(params) {
|
|
72
|
-
const
|
|
73
|
-
|
|
71
|
+
const config = GhostMarketNDSEthereum.CONFIG_BY_NETWORK_ID[__classPrivateFieldGet(this, _GhostMarketNDSEthereum_network, "f").id];
|
|
72
|
+
if (!config)
|
|
73
|
+
throw new Error('Unsupported network');
|
|
74
|
+
const parameters = query_string_1.default.stringify(Object.assign({ chain: config.chain }, params), { arrayFormat: 'bracket' });
|
|
75
|
+
return `${config.url}/assets?${parameters}`;
|
|
74
76
|
}
|
|
75
77
|
parse(data) {
|
|
76
78
|
var _a, _b;
|
|
@@ -92,4 +94,10 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
exports.GhostMarketNDSEthereum = GhostMarketNDSEthereum;
|
|
95
|
-
|
|
97
|
+
_GhostMarketNDSEthereum_network = new WeakMap();
|
|
98
|
+
GhostMarketNDSEthereum.CONFIG_BY_NETWORK_ID = {
|
|
99
|
+
'1': {
|
|
100
|
+
url: 'https://api.ghostmarket.io/api/v2',
|
|
101
|
+
chain: 'eth',
|
|
102
|
+
},
|
|
103
|
+
};
|
package/dist/RpcBDSEthereum.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { AvailableNetworkIds } from './
|
|
2
|
+
import { AvailableNetworkIds } from './BSEthereumHelper';
|
|
3
3
|
export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
4
4
|
#private;
|
|
5
5
|
maxTimeToConfirmTransactionInMs: number;
|
package/dist/RpcBDSEthereum.js
CHANGED
|
@@ -23,8 +23,8 @@ var _RpcBDSEthereum_network;
|
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.RpcBDSEthereum = void 0;
|
|
25
25
|
const ethers_1 = require("ethers");
|
|
26
|
-
const constants_1 = require("./constants");
|
|
27
26
|
const ERC20_1 = require("./assets/abis/ERC20");
|
|
27
|
+
const BSEthereumHelper_1 = require("./BSEthereumHelper");
|
|
28
28
|
class RpcBDSEthereum {
|
|
29
29
|
constructor(network) {
|
|
30
30
|
_RpcBDSEthereum_network.set(this, void 0);
|
|
@@ -40,7 +40,7 @@ class RpcBDSEthereum {
|
|
|
40
40
|
const block = yield provider.getBlock(transaction.blockHash);
|
|
41
41
|
if (!block)
|
|
42
42
|
throw new Error('Block not found');
|
|
43
|
-
const token =
|
|
43
|
+
const token = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f"));
|
|
44
44
|
return {
|
|
45
45
|
block: block.number,
|
|
46
46
|
time: block.timestamp,
|
|
@@ -71,8 +71,9 @@ class RpcBDSEthereum {
|
|
|
71
71
|
}
|
|
72
72
|
getTokenInfo(hash) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f"));
|
|
75
|
+
if (nativeAsset.hash === hash)
|
|
76
|
+
return nativeAsset;
|
|
76
77
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").url);
|
|
77
78
|
const contract = new ethers_1.ethers.Contract(hash, ERC20_1.ERC20_ABI, provider);
|
|
78
79
|
const decimals = yield contract.decimals();
|
|
@@ -89,7 +90,7 @@ class RpcBDSEthereum {
|
|
|
89
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
91
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").url);
|
|
91
92
|
const balance = yield provider.getBalance(address);
|
|
92
|
-
const token =
|
|
93
|
+
const token = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f"));
|
|
93
94
|
return [
|
|
94
95
|
{
|
|
95
96
|
amount: ethers_1.ethers.utils.formatEther(balance),
|
|
@@ -107,7 +108,8 @@ class RpcBDSEthereum {
|
|
|
107
108
|
getRpcList() {
|
|
108
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
110
|
const list = [];
|
|
110
|
-
const
|
|
111
|
+
const urls = BSEthereumHelper_1.BSEthereumHelper.getRpcList(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f"));
|
|
112
|
+
const promises = urls.map(url => {
|
|
111
113
|
// eslint-disable-next-line no-async-promise-executor
|
|
112
114
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
113
115
|
const timeout = setTimeout(() => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from './BSEthereum';
|
|
2
2
|
export * from './GhostMarketNDSEthereum';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './RpcNDSEthereum';
|
|
4
|
+
export * from './BSEthereumHelper';
|
|
4
5
|
export * from './BitqueryBDSEthereum';
|
|
5
|
-
export * from './BitqueryEDSEthereum';
|
|
6
6
|
export * from './RpcBDSEthereum';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './BitqueryEDSEthereum';
|
|
8
|
+
export * from './EthersLedgerServiceEthereum';
|
package/dist/index.js
CHANGED
|
@@ -16,8 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./BSEthereum"), exports);
|
|
18
18
|
__exportStar(require("./GhostMarketNDSEthereum"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./RpcNDSEthereum"), exports);
|
|
20
|
+
__exportStar(require("./BSEthereumHelper"), exports);
|
|
20
21
|
__exportStar(require("./BitqueryBDSEthereum"), exports);
|
|
21
|
-
__exportStar(require("./BitqueryEDSEthereum"), exports);
|
|
22
22
|
__exportStar(require("./RpcBDSEthereum"), exports);
|
|
23
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./BitqueryEDSEthereum"), exports);
|
|
24
|
+
__exportStar(require("./EthersLedgerServiceEthereum"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@ledgerhq/hw-app-eth": "~6.35.7",
|
|
23
23
|
"@ethersproject/abstract-signer": "~5.7.0",
|
|
24
24
|
"@ethersproject/properties": "~5.7.0",
|
|
25
|
-
"@cityofzion/blockchain-service": "1.0.
|
|
25
|
+
"@cityofzion/blockchain-service": "1.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
|
@@ -1,51 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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';
|
|
3
|
-
export declare const DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
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
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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");
|
|
5
|
-
exports.DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
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': [
|
|
26
|
-
'https://eth.llamarpc.com',
|
|
27
|
-
'https://mainnet.infura.io/v3/',
|
|
28
|
-
'https://ethereum-rpc.publicnode.com',
|
|
29
|
-
'https://endpoints.omniatech.io/v1/eth/mainnet/public',
|
|
30
|
-
'https://rpc.flashbots.net',
|
|
31
|
-
'https://rpc.mevblocker.io',
|
|
32
|
-
],
|
|
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',
|
|
102
|
-
'https://ethereum-sepolia-rpc.publicnode.com',
|
|
103
|
-
'https://endpoints.omniatech.io/v1/eth/sepolia/public',
|
|
104
|
-
'https://eth-sepolia.public.blastapi.io',
|
|
105
|
-
'https://eth-sepolia-public.unifra.io',
|
|
106
|
-
'https://1rpc.io/sepolia',
|
|
107
|
-
'https://eth-sepolia.api.onfinality.io/public',
|
|
108
|
-
],
|
|
109
|
-
'12227331': ['https://neoxseed1.ngd.network'],
|
|
110
|
-
};
|
|
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',
|
|
160
|
-
};
|