@cityofzion/bs-ethereum 2.13.3 → 2.13.5
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 +28 -23
- package/dist/BSEthereum.js +60 -24
- package/dist/constants/BSEthereumConstants.d.ts +9 -19
- package/dist/constants/BSEthereumConstants.js +100 -101
- package/dist/helpers/BSEthereumHelper.d.ts +4 -7
- package/dist/helpers/BSEthereumHelper.js +3 -9
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/services/blockchain-data/MoralisBDSEthereum.d.ts +20 -15
- package/dist/services/blockchain-data/MoralisBDSEthereum.js +105 -146
- package/dist/services/blockchain-data/RpcBDSEthereum.d.ts +14 -15
- package/dist/services/blockchain-data/RpcBDSEthereum.js +35 -54
- package/dist/services/exchange-data/MoralisEDSEthereum.d.ts +9 -6
- package/dist/services/exchange-data/MoralisEDSEthereum.js +47 -41
- package/dist/services/explorer/BlockscoutESEthereum.d.ts +8 -6
- package/dist/services/explorer/BlockscoutESEthereum.js +29 -48
- package/dist/services/ledger/EthersLedgerServiceEthereum.d.ts +9 -8
- package/dist/services/ledger/EthersLedgerServiceEthereum.js +33 -19
- package/dist/services/nft-data/GhostMarketNDSEthereum.d.ts +8 -11
- package/dist/services/nft-data/GhostMarketNDSEthereum.js +32 -92
- package/dist/types.d.ts +83 -0
- package/dist/types.js +2 -0
- package/package.json +20 -22
- package/dist/services/blockchain-data/DoraBDSEthereum.d.ts +0 -12
- package/dist/services/blockchain-data/DoraBDSEthereum.js +0 -40
- package/dist/services/nft-data/RpcNDSEthereum.d.ts +0 -8
- package/dist/services/nft-data/RpcNDSEthereum.js +0 -50
package/dist/BSEthereum.d.ts
CHANGED
|
@@ -1,35 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TBSAccount, TBSToken, TTransferParam, TGetLedgerTransport, ITokenService, TBSNetwork, IBlockchainDataService, IExchangeDataService, INftDataService, IExplorerService, TPingNetworkResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
-
import { BSEthereumNetworkId } from './constants/BSEthereumConstants';
|
|
4
3
|
import { EthersLedgerServiceEthereum } from './services/ledger/EthersLedgerServiceEthereum';
|
|
5
|
-
|
|
4
|
+
import { IBSEthereum, TBSEthereumNetworkId, TSupportedEVM } from './types';
|
|
5
|
+
export declare class BSEthereum<N extends string = string, A extends string = TBSEthereumNetworkId> implements IBSEthereum<N, A> {
|
|
6
6
|
#private;
|
|
7
|
-
readonly name:
|
|
7
|
+
readonly name: N;
|
|
8
8
|
readonly bip44DerivationPath: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
readonly isMultiTransferSupported = false;
|
|
10
|
+
readonly isCustomNetworkSupported = false;
|
|
11
|
+
tokens: TBSToken[];
|
|
12
|
+
nativeTokens: TBSToken[];
|
|
13
|
+
feeToken: TBSToken;
|
|
14
|
+
network: TBSNetwork<A>;
|
|
15
|
+
availableNetworkURLs: string[];
|
|
16
|
+
readonly defaultNetwork: TBSNetwork<A>;
|
|
17
|
+
readonly availableNetworks: TBSNetwork<A>[];
|
|
18
|
+
blockchainDataService: IBlockchainDataService;
|
|
19
|
+
exchangeDataService: IExchangeDataService;
|
|
20
|
+
ledgerService: EthersLedgerServiceEthereum<N>;
|
|
21
|
+
nftDataService: INftDataService;
|
|
22
|
+
explorerService: IExplorerService;
|
|
18
23
|
tokenService: ITokenService;
|
|
19
|
-
constructor(name:
|
|
20
|
-
generateSigner(account:
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
constructor(name: N, evm?: TSupportedEVM, network?: TBSNetwork<A>, getLedgerTransport?: TGetLedgerTransport<N>);
|
|
25
|
+
generateSigner(account: TBSAccount<N>): Promise<ethers.Signer>;
|
|
26
|
+
setNetwork(network: TBSNetwork<A>): void;
|
|
27
|
+
pingNetwork(network: TBSNetwork<A>): Promise<TPingNetworkResponse>;
|
|
23
28
|
validateAddress(address: string): boolean;
|
|
24
29
|
validateEncrypted(json: string): boolean;
|
|
25
30
|
validateKey(key: string): boolean;
|
|
26
31
|
validateNameServiceDomainFormat(domainName: string): boolean;
|
|
27
|
-
generateAccountFromMnemonic(mnemonic: string[] | string, index: number):
|
|
28
|
-
generateAccountFromKey(key: string):
|
|
29
|
-
generateAccountFromPublicKey(publicKey: string):
|
|
30
|
-
decrypt(json: string, password: string): Promise<
|
|
32
|
+
generateAccountFromMnemonic(mnemonic: string[] | string, index: number): TBSAccount<N>;
|
|
33
|
+
generateAccountFromKey(key: string): TBSAccount<N>;
|
|
34
|
+
generateAccountFromPublicKey(publicKey: string): TBSAccount<N>;
|
|
35
|
+
decrypt(json: string, password: string): Promise<TBSAccount<N>>;
|
|
31
36
|
encrypt(key: string, password: string): Promise<string>;
|
|
32
|
-
transfer(param:
|
|
33
|
-
calculateTransferFee(param:
|
|
37
|
+
transfer(param: TTransferParam<N>): Promise<string[]>;
|
|
38
|
+
calculateTransferFee(param: TTransferParam<N>): Promise<string>;
|
|
34
39
|
resolveNameServiceDomain(domainName: string): Promise<string>;
|
|
35
40
|
}
|
package/dist/BSEthereum.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -36,9 +46,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
46
|
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
47
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
38
48
|
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
39
52
|
var _BSEthereum_instances, _BSEthereum_buildTransferParams, _BSEthereum_setTokens;
|
|
40
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
54
|
exports.BSEthereum = void 0;
|
|
55
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
42
56
|
const ethers_1 = require("ethers");
|
|
43
57
|
const ethersJsonWallets = __importStar(require("@ethersproject/json-wallets"));
|
|
44
58
|
const ethersBytes = __importStar(require("@ethersproject/bytes"));
|
|
@@ -50,16 +64,21 @@ const MoralisBDSEthereum_1 = require("./services/blockchain-data/MoralisBDSEther
|
|
|
50
64
|
const MoralisEDSEthereum_1 = require("./services/exchange-data/MoralisEDSEthereum");
|
|
51
65
|
const GhostMarketNDSEthereum_1 = require("./services/nft-data/GhostMarketNDSEthereum");
|
|
52
66
|
const BlockscoutESEthereum_1 = require("./services/explorer/BlockscoutESEthereum");
|
|
53
|
-
const RpcBDSEthereum_1 = require("./services/blockchain-data/RpcBDSEthereum");
|
|
54
67
|
const TokenServiceEthereum_1 = require("./services/token/TokenServiceEthereum");
|
|
68
|
+
const axios_1 = __importDefault(require("axios"));
|
|
55
69
|
class BSEthereum {
|
|
56
|
-
constructor(name, network, getLedgerTransport) {
|
|
70
|
+
constructor(name, evm, network, getLedgerTransport) {
|
|
57
71
|
_BSEthereum_instances.add(this);
|
|
58
|
-
|
|
72
|
+
this.isMultiTransferSupported = false;
|
|
73
|
+
this.isCustomNetworkSupported = false;
|
|
59
74
|
this.name = name;
|
|
60
75
|
this.ledgerService = new EthersLedgerServiceEthereum_1.EthersLedgerServiceEthereum(this, getLedgerTransport);
|
|
61
76
|
this.bip44DerivationPath = BSEthereumConstants_1.BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH;
|
|
62
|
-
|
|
77
|
+
if (!evm)
|
|
78
|
+
return;
|
|
79
|
+
this.availableNetworks = BSEthereumConstants_1.BSEthereumConstants.NETWORKS_BY_EVM[evm];
|
|
80
|
+
this.defaultNetwork = this.availableNetworks.find(network => network.type === 'mainnet');
|
|
81
|
+
this.setNetwork(network !== null && network !== void 0 ? network : this.defaultNetwork);
|
|
63
82
|
}
|
|
64
83
|
generateSigner(account) {
|
|
65
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -75,21 +94,38 @@ class BSEthereum {
|
|
|
75
94
|
return new ethers_1.ethers.Wallet(account.key, provider);
|
|
76
95
|
});
|
|
77
96
|
}
|
|
78
|
-
testNetwork(network) {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
this.tokenService = new TokenServiceEthereum_1.TokenServiceEthereum();
|
|
81
|
-
const blockchainDataServiceClone = new RpcBDSEthereum_1.RpcBDSEthereum(network, this.tokenService);
|
|
82
|
-
yield blockchainDataServiceClone.getBlockHeight();
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
97
|
setNetwork(network) {
|
|
98
|
+
const availableURLs = BSEthereumConstants_1.BSEthereumConstants.RPC_LIST_BY_NETWORK_ID[network.id] || [];
|
|
99
|
+
const isValidNetwork = blockchain_service_1.BSUtilsHelper.validateNetwork(network, this.availableNetworks, availableURLs);
|
|
100
|
+
if (!isValidNetwork) {
|
|
101
|
+
throw new Error(`Network with id ${network.id} is not available for ${this.name}`);
|
|
102
|
+
}
|
|
86
103
|
__classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_setTokens).call(this, network);
|
|
87
104
|
this.network = network;
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
105
|
+
this.availableNetworkURLs = availableURLs;
|
|
106
|
+
this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(this);
|
|
107
|
+
this.explorerService = new BlockscoutESEthereum_1.BlockscoutESEthereum(this);
|
|
108
|
+
this.exchangeDataService = new MoralisEDSEthereum_1.MoralisEDSEthereum(this);
|
|
109
|
+
this.blockchainDataService = new MoralisBDSEthereum_1.MoralisBDSEthereum(this);
|
|
91
110
|
this.tokenService = new TokenServiceEthereum_1.TokenServiceEthereum();
|
|
92
|
-
|
|
111
|
+
}
|
|
112
|
+
// This method is done manually because we need to ensure that the request is aborted after timeout
|
|
113
|
+
pingNetwork(network) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const abortController = new AbortController();
|
|
116
|
+
const timeout = setTimeout(() => {
|
|
117
|
+
abortController.abort();
|
|
118
|
+
}, 5000);
|
|
119
|
+
const timeStart = Date.now();
|
|
120
|
+
const response = yield axios_1.default.post(network.url, { jsonrpc: '2.0', method: 'eth_blockNumber', params: [], id: 1234 }, { timeout: 5000, signal: abortController.signal });
|
|
121
|
+
clearTimeout(timeout);
|
|
122
|
+
const latency = Date.now() - timeStart;
|
|
123
|
+
return {
|
|
124
|
+
latency,
|
|
125
|
+
url: network.url,
|
|
126
|
+
height: ethers_1.ethers.BigNumber.from(response.data.result).toNumber(),
|
|
127
|
+
};
|
|
128
|
+
});
|
|
93
129
|
}
|
|
94
130
|
validateAddress(address) {
|
|
95
131
|
return ethers_1.ethers.utils.isAddress(address);
|
|
@@ -104,7 +140,7 @@ class BSEthereum {
|
|
|
104
140
|
}
|
|
105
141
|
return ethersBytes.hexDataLength(key) === 32;
|
|
106
142
|
}
|
|
107
|
-
catch (
|
|
143
|
+
catch (_a) {
|
|
108
144
|
return false;
|
|
109
145
|
}
|
|
110
146
|
}
|
|
@@ -220,7 +256,7 @@ _BSEthereum_instances = new WeakSet(), _BSEthereum_buildTransferParams = functio
|
|
|
220
256
|
const token = yield this.blockchainDataService.getTokenInfo(intent.tokenHash);
|
|
221
257
|
decimals = token.decimals;
|
|
222
258
|
}
|
|
223
|
-
catch (
|
|
259
|
+
catch (_a) {
|
|
224
260
|
decimals = 18;
|
|
225
261
|
}
|
|
226
262
|
}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TBSNetwork } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { TBSEthereumNetworkId, TSupportedEVM } from '../types';
|
|
3
3
|
export declare class BSEthereumConstants {
|
|
4
|
-
static DEFAULT_DECIMALS
|
|
5
|
-
static DEFAULT_GAS_LIMIT
|
|
6
|
-
static readonly
|
|
7
|
-
static readonly
|
|
8
|
-
static readonly
|
|
9
|
-
static readonly
|
|
10
|
-
static
|
|
11
|
-
static NATIVE_WRAPPED_HASH_BY_NETWORK_ID: Partial<Record<BSEthereumNetworkId, string>>;
|
|
12
|
-
static RPC_LIST_BY_NETWORK_ID: Record<BSEthereumNetworkId, string[]>;
|
|
13
|
-
static DEFAULT_BIP44_DERIVATION_PATH: string;
|
|
14
|
-
static MAINNET_NETWORK_IDS: BSEthereumNetworkId[];
|
|
15
|
-
static TESTNET_NETWORK_IDS: BSEthereumNetworkId[];
|
|
16
|
-
static ALL_NETWORK_IDS: BSEthereumNetworkId[];
|
|
17
|
-
static MAINNET_NETWORKS: Network<BSEthereumNetworkId>[];
|
|
18
|
-
static TESTNET_NETWORKS: Network<BSEthereumNetworkId>[];
|
|
19
|
-
static ALL_NETWORKS: Network<BSEthereumNetworkId>[];
|
|
20
|
-
static DEFAULT_NETWORK: Network<BSEthereumNetworkId>;
|
|
4
|
+
static readonly DEFAULT_DECIMALS = 18;
|
|
5
|
+
static readonly DEFAULT_GAS_LIMIT = 21000;
|
|
6
|
+
static readonly DEFAULT_BIP44_DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
7
|
+
static readonly NATIVE_SYMBOL_BY_NETWORK_ID: Record<TBSEthereumNetworkId, string>;
|
|
8
|
+
static readonly NATIVE_WRAPPED_HASH_BY_NETWORK_ID: Partial<Record<TBSEthereumNetworkId, string>>;
|
|
9
|
+
static readonly RPC_LIST_BY_NETWORK_ID: Record<TBSEthereumNetworkId, string[]>;
|
|
10
|
+
static readonly NETWORKS_BY_EVM: Record<TSupportedEVM, TBSNetwork<TBSEthereumNetworkId>[]>;
|
|
21
11
|
}
|
|
@@ -8,10 +8,7 @@ exports.BSEthereumConstants = BSEthereumConstants;
|
|
|
8
8
|
_a = BSEthereumConstants;
|
|
9
9
|
BSEthereumConstants.DEFAULT_DECIMALS = 18;
|
|
10
10
|
BSEthereumConstants.DEFAULT_GAS_LIMIT = 0x5208;
|
|
11
|
-
BSEthereumConstants.
|
|
12
|
-
BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID = '137';
|
|
13
|
-
BSEthereumConstants.BASE_MAINNET_NETWORK_ID = '8453';
|
|
14
|
-
BSEthereumConstants.ARBITRUM_MAINNET_NETWORK_ID = '42161';
|
|
11
|
+
BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/60'/0'/0/?";
|
|
15
12
|
BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID = {
|
|
16
13
|
'1': 'ETH',
|
|
17
14
|
'10': 'ETH',
|
|
@@ -29,14 +26,14 @@ BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID = {
|
|
|
29
26
|
'11155111': 'ETH',
|
|
30
27
|
};
|
|
31
28
|
BSEthereumConstants.NATIVE_WRAPPED_HASH_BY_NETWORK_ID = {
|
|
32
|
-
|
|
29
|
+
'1': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
33
30
|
'10': '0x4200000000000000000000000000000000000006',
|
|
34
31
|
'25': '0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23',
|
|
35
32
|
'56': '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c',
|
|
36
|
-
|
|
33
|
+
'137': '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
|
|
37
34
|
'250': '0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83',
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
'8453': '0x4200000000000000000000000000000000000006',
|
|
36
|
+
'42161': '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
|
|
40
37
|
'42220': '0x471EcE3750Da237f93B8E339c536989b8978a438',
|
|
41
38
|
'43114': '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7',
|
|
42
39
|
'59144': '0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f',
|
|
@@ -126,96 +123,98 @@ BSEthereumConstants.RPC_LIST_BY_NETWORK_ID = {
|
|
|
126
123
|
'https://endpoints.omniatech.io/v1/eth/sepolia/public',
|
|
127
124
|
],
|
|
128
125
|
};
|
|
129
|
-
BSEthereumConstants.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
126
|
+
BSEthereumConstants.NETWORKS_BY_EVM = {
|
|
127
|
+
ethereum: [
|
|
128
|
+
{
|
|
129
|
+
id: '1',
|
|
130
|
+
name: 'Ethereum Mainnet',
|
|
131
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['1'][0],
|
|
132
|
+
type: 'mainnet',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: '11155111',
|
|
136
|
+
name: 'Sepolia Testnet',
|
|
137
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['11155111'][0],
|
|
138
|
+
type: 'testnet',
|
|
139
|
+
},
|
|
140
|
+
// EVM compatible networks
|
|
141
|
+
{
|
|
142
|
+
id: '10',
|
|
143
|
+
name: 'Optimism Mainnet',
|
|
144
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['10'][0],
|
|
145
|
+
type: 'mainnet',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: '25',
|
|
149
|
+
name: 'Cronos Mainnet',
|
|
150
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['25'][0],
|
|
151
|
+
type: 'mainnet',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: '56',
|
|
155
|
+
name: 'Binance Smart Chain Mainnet',
|
|
156
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['56'][0],
|
|
157
|
+
type: 'mainnet',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: '250',
|
|
161
|
+
name: 'Fantom Mainnet',
|
|
162
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['250'][0],
|
|
163
|
+
type: 'mainnet',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: '42220',
|
|
167
|
+
name: 'Celo Mainnet',
|
|
168
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['42220'][0],
|
|
169
|
+
type: 'mainnet',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: '43114',
|
|
173
|
+
name: 'Avalanche Mainnet',
|
|
174
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['43114'][0],
|
|
175
|
+
type: 'mainnet',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: '59144',
|
|
179
|
+
name: 'Linea Mainnet',
|
|
180
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['59144'][0],
|
|
181
|
+
type: 'mainnet',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
arbitrum: [
|
|
185
|
+
{
|
|
186
|
+
id: '42161',
|
|
187
|
+
name: 'Arbitrum Mainnet',
|
|
188
|
+
url: _a.RPC_LIST_BY_NETWORK_ID[42161][0],
|
|
189
|
+
type: 'mainnet',
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
base: [
|
|
193
|
+
{
|
|
194
|
+
id: '8453',
|
|
195
|
+
name: 'Base Protocol Mainnet',
|
|
196
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['8453'][0],
|
|
197
|
+
type: 'mainnet',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
polygon: [
|
|
201
|
+
{
|
|
202
|
+
id: '137',
|
|
203
|
+
name: 'Polygon Mainnet',
|
|
204
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['137'][0],
|
|
205
|
+
type: 'mainnet',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: '1101',
|
|
209
|
+
name: 'Polygon zkEVM Testnet',
|
|
210
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['1101'][0],
|
|
211
|
+
type: 'testnet',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
id: '80002',
|
|
215
|
+
name: 'Polygon Testnet Amoy',
|
|
216
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['80002'][0],
|
|
217
|
+
type: 'testnet',
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TokenServiceEthereum } from '../services/token/TokenServiceEthereum';
|
|
1
|
+
import { TBSNetwork, TBSNetworkId } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { IBSEthereum, TBSEthereumNetworkId } from '../types';
|
|
4
3
|
export declare class BSEthereumHelper {
|
|
5
|
-
static
|
|
6
|
-
static getNativeAsset(network: Network<BSEthereumNetworkId>): {
|
|
4
|
+
static getNativeAsset(network: TBSNetwork<TBSEthereumNetworkId>): {
|
|
7
5
|
symbol: string;
|
|
8
6
|
name: string;
|
|
9
7
|
decimals: number;
|
|
10
8
|
hash: string;
|
|
11
9
|
};
|
|
12
|
-
static
|
|
13
|
-
static isMainnet(network: Network<BSEthereumNetworkId>): boolean;
|
|
10
|
+
static isMainnetNetwork<N extends string, A extends TBSNetworkId>(service: IBSEthereum<N, A>): boolean;
|
|
14
11
|
}
|
|
@@ -2,20 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BSEthereumHelper = void 0;
|
|
4
4
|
const BSEthereumConstants_1 = require("../constants/BSEthereumConstants");
|
|
5
|
-
const TokenServiceEthereum_1 = require("../services/token/TokenServiceEthereum");
|
|
6
5
|
class BSEthereumHelper {
|
|
7
6
|
static getNativeAsset(network) {
|
|
8
7
|
var _a;
|
|
9
8
|
const symbol = (_a = BSEthereumConstants_1.BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : 'ETH';
|
|
10
|
-
return { symbol, name: symbol, decimals: 18, hash:
|
|
9
|
+
return { symbol, name: symbol, decimals: 18, hash: '0x' };
|
|
11
10
|
}
|
|
12
|
-
static
|
|
13
|
-
|
|
14
|
-
return (_a = BSEthereumConstants_1.BSEthereumConstants.RPC_LIST_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : [];
|
|
15
|
-
}
|
|
16
|
-
static isMainnet(network) {
|
|
17
|
-
return BSEthereumConstants_1.BSEthereumConstants.MAINNET_NETWORK_IDS.includes(network.id);
|
|
11
|
+
static isMainnetNetwork(service) {
|
|
12
|
+
return (service.network.type === 'mainnet' && service.availableNetworks.some(network => network.id === service.network.id));
|
|
18
13
|
}
|
|
19
14
|
}
|
|
20
15
|
exports.BSEthereumHelper = BSEthereumHelper;
|
|
21
|
-
BSEthereumHelper.tokenService = new TokenServiceEthereum_1.TokenServiceEthereum();
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,12 @@ export * from './BSEthereum';
|
|
|
2
2
|
export * from './helpers/BSEthereumHelper';
|
|
3
3
|
export * from './constants/BSEthereumConstants';
|
|
4
4
|
export * from './services/blockchain-data/MoralisBDSEthereum';
|
|
5
|
-
export * from './services/blockchain-data/DoraBDSEthereum';
|
|
6
5
|
export * from './services/blockchain-data/RpcBDSEthereum';
|
|
7
6
|
export * from './services/exchange-data/MoralisEDSEthereum';
|
|
8
7
|
export * from './services/explorer/BlockscoutESEthereum';
|
|
9
8
|
export * from './services/ledger/EthersLedgerServiceEthereum';
|
|
10
9
|
export * from './services/nft-data/GhostMarketNDSEthereum';
|
|
11
|
-
export * from './services/nft-data/RpcNDSEthereum';
|
|
12
10
|
export * from './services/token/TokenServiceEthereum';
|
|
13
11
|
export * from './assets/abis/ERC20';
|
|
14
12
|
export * from './assets/abis/ERC721';
|
|
13
|
+
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -18,13 +18,12 @@ __exportStar(require("./BSEthereum"), exports);
|
|
|
18
18
|
__exportStar(require("./helpers/BSEthereumHelper"), exports);
|
|
19
19
|
__exportStar(require("./constants/BSEthereumConstants"), exports);
|
|
20
20
|
__exportStar(require("./services/blockchain-data/MoralisBDSEthereum"), exports);
|
|
21
|
-
__exportStar(require("./services/blockchain-data/DoraBDSEthereum"), exports);
|
|
22
21
|
__exportStar(require("./services/blockchain-data/RpcBDSEthereum"), exports);
|
|
23
22
|
__exportStar(require("./services/exchange-data/MoralisEDSEthereum"), exports);
|
|
24
23
|
__exportStar(require("./services/explorer/BlockscoutESEthereum"), exports);
|
|
25
24
|
__exportStar(require("./services/ledger/EthersLedgerServiceEthereum"), exports);
|
|
26
25
|
__exportStar(require("./services/nft-data/GhostMarketNDSEthereum"), exports);
|
|
27
|
-
__exportStar(require("./services/nft-data/RpcNDSEthereum"), exports);
|
|
28
26
|
__exportStar(require("./services/token/TokenServiceEthereum"), exports);
|
|
29
27
|
__exportStar(require("./assets/abis/ERC20"), exports);
|
|
30
28
|
__exportStar(require("./assets/abis/ERC721"), exports);
|
|
29
|
+
__exportStar(require("./types"), exports);
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { TBalanceResponse, ContractResponse, TBSToken, TTransactionResponse, TTransactionsByAddressParams, TTransactionsByAddressResponse, TFullTransactionsByAddressParams, TFullTransactionsByAddressResponse, TExportTransactionsByAddressParams, TBSNetwork, TBSNetworkId } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
import { IBSEthereum, TBSEthereumNetworkId } from '../../types';
|
|
4
|
+
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
5
|
+
export declare class MoralisBDSEthereum<N extends string, A extends TBSNetworkId> extends RpcBDSEthereum<N, A> {
|
|
5
6
|
#private;
|
|
6
|
-
static BASE_URL: string;
|
|
7
|
-
static
|
|
8
|
-
static
|
|
9
|
-
static
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
static readonly BASE_URL: string;
|
|
8
|
+
static readonly FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS: TBSEthereumNetworkId[];
|
|
9
|
+
static readonly FULL_TRANSACTIONS_ERC721_STANDARDS: string[];
|
|
10
|
+
static readonly FULL_TRANSACTIONS_ERC1155_STANDARDS: string[];
|
|
11
|
+
static readonly FULL_TRANSACTIONS_ERC20_STANDARDS: string[];
|
|
12
|
+
static readonly MORALIS_SUPPORTED_NETWORKS_IDS: TBSEthereumNetworkId[];
|
|
13
|
+
static getClient(network: TBSNetwork<TBSEthereumNetworkId>): AxiosInstance;
|
|
14
|
+
static isSupported(network: TBSNetwork<TBSEthereumNetworkId>): boolean;
|
|
15
|
+
constructor(service: IBSEthereum<N, A>);
|
|
16
|
+
getBalance(address: string): Promise<TBalanceResponse[]>;
|
|
17
|
+
getTokenInfo(hash: string): Promise<TBSToken>;
|
|
18
|
+
getTransaction(hash: string): Promise<TTransactionResponse>;
|
|
19
|
+
getTransactionsByAddress(params: TTransactionsByAddressParams): Promise<TTransactionsByAddressResponse>;
|
|
20
|
+
getFullTransactionsByAddress({ nextCursor, ...params }: TFullTransactionsByAddressParams): Promise<TFullTransactionsByAddressResponse>;
|
|
21
|
+
exportFullTransactionsByAddress(params: TExportTransactionsByAddressParams): Promise<string>;
|
|
17
22
|
getContract(hash: string): Promise<ContractResponse>;
|
|
18
23
|
}
|