@iexec/iexec-oracle-factory-wrapper
Version:
A wrapper for creating API based oracles for ethereum on the top of iExec
71 lines • 2.71 kB
JavaScript
import { getDefaultProvider as getEthersDefaultProvider, } from 'ethers';
const API_KEY_PLACEHOLDER = '%API_KEY%';
const factoryConfMap = {
134: {
ORACLE_APP_ADDRESS: 'oracle-factory.apps.iexec.eth',
ORACLE_APP_WHITELIST_ADDRESS: '0x26472b355849B409769545A8595fe97846a8F0C9',
ORACLE_CONTRACT_ADDRESS: '0x36dA71ccAd7A67053f0a4d9D5f55b725C9A25A3E',
WORKERPOOL_ADDRESS: 'prod-v8-bellecour.main.pools.iexec.eth',
},
};
const readerConfMap = {
1: {
ORACLE_CONTRACT_ADDRESS: '0x36dA71ccAd7A67053f0a4d9D5f55b725C9A25A3E',
},
134: {
ORACLE_CONTRACT_ADDRESS: factoryConfMap[134].ORACLE_CONTRACT_ADDRESS,
},
137: {
ORACLE_CONTRACT_ADDRESS: '0x36dA71ccAd7A67053f0a4d9D5f55b725C9A25A3E',
},
80002: {
ORACLE_CONTRACT_ADDRESS: '0x36dA71ccAd7A67053f0a4d9D5f55b725C9A25A3E',
},
11155111: {
ORACLE_CONTRACT_ADDRESS: '0x36dA71ccAd7A67053f0a4d9D5f55b725C9A25A3E',
},
};
const networkMap = {
1: 'homestead',
134: 'https://bellecour.iex.ec',
137: 'matic',
80002: 'https://rpc-amoy.polygon.technology',
11155111: 'sepolia',
mainnet: 'homestead',
bellecour: 'https://bellecour.iex.ec',
polygon: 'matic',
amoy: 'https://rpc-amoy.polygon.technology',
sepolia: 'sepolia',
};
const DEFAULT_IPFS_GATEWAY = 'https://ipfs-gateway.v8-bellecour.iex.ec';
const DEFAULT_IPFS_UPLOAD_URL = '/dns4/ipfs-upload.v8-bellecour.iex.ec/https';
const SUPPORTED_TARGET_BLOCKCHAINS = [1, 137, 80002, 11155111];
const DEFAULT_TARGET_BLOCKCHAIN = [];
const getDefaultProvider = (network = 134,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options) => {
const resolvedNetwork = networkMap[network] || network || networkMap[134];
return getEthersDefaultProvider(resolvedNetwork, options);
};
const getFactoryDefaults = (chainId) => {
const conf = factoryConfMap[chainId];
if (!conf)
throw Error(`Unsupported chain ${chainId}`);
return conf;
};
const getReaderDefaults = (chainId) => {
const conf = readerConfMap[chainId];
if (!conf)
throw Error(`Unsupported chain ${chainId}`);
return conf;
};
const getDefaults = (chainId) => {
const factoryConf = factoryConfMap[chainId];
const readerConf = readerConfMap[chainId];
const conf = { ...factoryConf, ...readerConf };
if (!factoryConf && !readerConf)
throw Error(`Unsupported chain ${chainId}`);
return conf;
};
export { API_KEY_PLACEHOLDER, DEFAULT_IPFS_GATEWAY, DEFAULT_IPFS_UPLOAD_URL, DEFAULT_TARGET_BLOCKCHAIN, SUPPORTED_TARGET_BLOCKCHAINS, getReaderDefaults, getFactoryDefaults, getDefaults, getDefaultProvider, };
//# sourceMappingURL=config.js.map