-
Notifications
You must be signed in to change notification settings - Fork 11
/
bsc.js
46 lines (34 loc) · 1.16 KB
/
bsc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"use strict";
const conf = require('ocore/conf.js');
const EvmChain = require('./evm-chain.js');
const { getProvider } = require("./evm/provider.js");
const { getAddressBlocks } = require("./etherscan.js");
const etherscan_base_url = process.env.testnet ? 'https://api-testnet.bscscan.com' : 'https://api.bscscan.com';
let bCreated = false;
class BSC extends EvmChain {
constructor() {
if (bCreated)
throw Error("BSC class already created, must be a singleton");
bCreated = true;
const provider = getProvider('BSC');
super('BSC', conf.bsc_factory_contract_addresses, conf.bsc_assistant_factory_contract_addresses, provider);
}
forget() {
console.log(`removing ${this.getProvider().listenerCount()} listeners on ${this.network}`);
this.getProvider().removeAllListeners();
bCreated = false;
}
getNativeSymbol() {
return 'BNB';
}
getMaxBlockRange() {
return 1000;
}
getStaticGasPrice() {
return process.env.testnet ? 5 : 3; // in gwei
}
async getAddressBlocks(address, startblock, startts) {
return await getAddressBlocks({ base_url: etherscan_base_url, address, startblock, startts, api_key: conf.bsc_api_key });
}
}
module.exports = BSC;