Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
providerConfigs = {
...providerConfigs,
fork: process.env.FORK_RPC_URL,
blockTime: 0,
unlocked_accounts: [
// ZeroExGovernor signer addresses
'0x257619b7155d247e43c8b6d90c8c17278ae481f0',
'0x5ee2a00f8f01d099451844af7f894f26a57fcbf2',
'0x894d623e0e0e8ed12c4a73dada999e275684a37d',
// ERC20BridgeProxy
'0x8ed95d1746bf1e4dab58d8ed4724f1ef95b20db0',
],
};
}
export const provider: Web3ProviderEngine = web3Factory.getRpcProvider(providerConfigs);
provider.stop();
const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage);
const isProfilerEnabled = env.parseBoolean(EnvVars.SolidityProfiler);
const isRevertTraceEnabled = env.parseBoolean(EnvVars.SolidityRevertTrace);
const enabledSubproviderCount = _.filter(
[isCoverageEnabled, isProfilerEnabled, isRevertTraceEnabled],
_.identity.bind(_),
).length;
if (enabledSubproviderCount > 1) {
throw new Error(`Only one of coverage, profiler, or revert trace subproviders can be enabled at a time`);
}
if (isCoverageEnabled) {
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
prependSubprovider(provider, coverageSubprovider);
}
if (isProfilerEnabled) {
export async function migrateOnceAsync(): Promise {
const txDefaults = {
gas: devConstants.GAS_LIMIT,
from: devConstants.TESTRPC_FIRST_ADDRESS,
};
const provider: Web3ProviderEngine = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
return runMigrationsOnceAsync(provider, txDefaults);
}
(async () => {
let providerConfigs;
let provider: Web3ProviderEngine;
let txDefaults;
const packageJsonPath = path.join(__dirname, '../..', 'package.json');
const packageJsonString = fs.readFileSync(packageJsonPath, 'utf8');
const packageJson = JSON.parse(packageJsonString);
if (packageJson.config === undefined || packageJson.config.snapshot_name === undefined) {
throw new Error(`Did not find 'snapshot_name' key in package.json config`);
}
providerConfigs = { shouldUseInProcessGanache: true, ganacheDatabasePath: packageJson.config.snapshot_name };
provider = web3Factory.getRpcProvider(providerConfigs);
txDefaults = {
from: devConstants.TESTRPC_FIRST_ADDRESS,
};
await runMigrationsAsync(provider, txDefaults);
process.exit(0);
})().catch(err => {
logUtils.log(err);
(async () => {
connection = await createConnection(ormConfig as ConnectionOptions);
const provider = web3Factory.getRpcProvider({
rpcUrl: INFURA_ROOT_URL,
});
const endBlock = await calculateEndBlockAsync(provider);
for (const token of tokensToGetApprovalEvents) {
await getAndSaveApprovalEventsAsync(provider, token, endBlock);
}
process.exit(0);
})().catch(handleError);
(async () => {
connection = await createConnection(ormConfig as ConnectionOptions);
const provider = web3Factory.getRpcProvider({
rpcUrl: INFURA_ROOT_URL,
});
const endBlock = await calculateEndBlockAsync(provider);
const eventsSource = new ExchangeEventsSource(provider, 1);
await getFillEventsAsync(eventsSource, endBlock);
await getCancelEventsAsync(eventsSource, endBlock);
await getCancelUpToEventsAsync(eventsSource, endBlock);
process.exit(0);
})().catch(handleError);
(async () => {
connection = await createConnection(ormConfig as ConnectionOptions);
const provider = web3Factory.getRpcProvider({
rpcUrl: `${INFURA_ROOT_URL}/${process.env.INFURA_API_KEY}`,
});
const web3Source = new Web3Source(provider);
await getAllMissingBlocks(web3Source);
process.exit(0);
})().catch(handleError);
async function getExchangeEventsAsync(): Promise {
console.log('Getting event logs...');
const provider = web3Factory.getRpcProvider({
rpcUrl: 'https://mainnet.infura.io',
});
const eventsRepository = connection.getRepository(ExchangeFillEvent);
const exchangeEvents = new ExchangeEventsSource(provider, 1);
const eventLogs = await exchangeEvents.getFillEventsAsync();
console.log('Parsing events...');
const events = parseExchangeEvents(eventLogs);
console.log(`Retrieved and parsed ${events.length} total events.`);
console.log('Saving events...');
for (const event of events) {
await eventsRepository.save(event);
}
await eventsRepository.save(events);
console.log('Saved events.');
}
(async () => {
let providerConfigs;
let provider: Web3ProviderEngine;
let txDefaults;
providerConfigs = { shouldUseInProcessGanache: false };
provider = web3Factory.getRpcProvider(providerConfigs);
txDefaults = {
from: devConstants.TESTRPC_FIRST_ADDRESS,
};
await runMigrationsAsync(provider, txDefaults);
process.exit(0);
})().catch(err => {
logUtils.log(err);
(async () => {
const apiKey = process.env.ETHERSCAN_API_KEY;
if (apiKey === undefined) {
throw new Error('Missing required env var: ETHERSCAN_API_KEY');
}
connection = await createConnection(ormConfig as ConnectionOptions);
const provider = web3Factory.getRpcProvider({
rpcUrl: INFURA_ROOT_URL,
});
const EtherscanTransactionRepository = connection.getRepository(EtherscanTransaction);
const startBlock = await getStartBlockAsync(EtherscanTransactionRepository);
logUtils.log(`Start block: ${startBlock}`);
const endBlock = await calculateEndBlockAsync(provider);
logUtils.log(`End block: ${endBlock}`);
const etherscanSource = new EtherscanSource(apiKey, startBlock, endBlock);
const exchangeContractAddress = getContractAddressesForNetworkOrThrow(NetworkId.Mainnet).exchange;
logUtils.log('Fetching exchange transactions from Etherscan...');
const rawTransactions = await etherscanSource.getEtherscanTransactionsForAddressAsync(exchangeContractAddress);
const transactions = parseEtherscanTransactions(rawTransactions);
logUtils.log(`Saving ${transactions.length} records to database`);
await EtherscanTransactionRepository.save(transactions, {
chunk: Math.ceil(transactions.length / BATCH_SAVE_SIZE),
});