UNPKG

@ixily/activ

Version:

Alpha Capture Trade Idea Verification. Blockchain ownership proven trade ideas and strategies.

113 lines 4.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigModule = void 0; const rxjs_1 = require("rxjs"); const __1 = require("../.."); const state = { singleConfig: false, config: {}, configUpdated$: new rxjs_1.BehaviorSubject(undefined), }; const updateModulesConfig = async () => { const _config = state.config; if (_config.nftStorageKey !== undefined || _config.mockNftStorage !== undefined) { await __1.NftStoreModule.config({ nftStorageKey: _config.nftStorageKey, mockNftStorage: _config.mockNftStorage, ipfsProxyEnabled: _config.ipfsProxyEnabled, usePinata: _config.usePinata, }); } if (_config.litConfig !== undefined) { await __1.LitModule.config({ litProvider: _config.litConfig.litProvider, mock: _config.litConfig.mock, }); } if ((0, __1.getBoolean)(_config.mockProvableValidation)) { __1.ProvableModule.config({ mockValidation: true, }); } if ((0, __1.getBoolean)(_config.mockLitPricing)) { __1.ProvableModule.config({ mockValidation: true, mockLitPricing: true, }); } const contract = __1.ContractModule.getBlockchainContract(); if (contract.name === 'hardhat') { __1.ProvableModule.config({ mockValidation: true, mockLitPricing: true, }); } if (_config.cacheStorageConfig !== undefined) { await __1.CacheStorageModule.config(_config.cacheStorageConfig); } if (_config.useProxyInPricing !== undefined) { __1.PricingModule.config({ useProxyUntrusted: _config.useProxyInPricing, }); } state.configUpdated$.next(state.config); }; const config = async (_config) => { if (!state.singleConfig) { if (!(_config.singleConfig === false)) { state.singleConfig = true; } _config.defaultBlockchainNetwork = _config.defaultBlockchainNetwork || 'amoy'; _config.defaultContract = _config.defaultContract || 'v4'; state.config = _config; // if (_config.contractRecipe !== undefined) { // await ContractModule.buildAndSet( // _config.contractRecipe, // _config.backendWalletPrivateKey, // _config.hardhatDemoWalletToUse, // ) // LitModule.setContract(_config.contractRecipe.coreContractAddress) // await updateModulesConfig() __1.ContractModule.getUpdatedStream().subscribe((indeed) => { if (indeed) { updateModulesConfig(); } }); const web3Auth = _config.web3AuthorizationOptions; if ((web3Auth.userWalletPrivateKey === undefined && web3Auth.webProvider === undefined) || (web3Auth.userWalletPrivateKey !== undefined && web3Auth.webProvider !== undefined)) { throw new Error('Config Module Error: defaultContractOptions must have either userWalletPrivateKey or webProvider, but not both'); } __1.ContractModule.changeToContract(_config.defaultBlockchainNetwork, _config.defaultContract, _config.web3AuthorizationOptions); await new Promise((resolve) => { state.configUpdated$.subscribe((indeed) => { if (indeed !== undefined) { resolve(undefined); } }); }); // } __1.LogModule.setLogStatus((0, __1.getBoolean)(_config.showLogsToDebug)); // if (_config?.mockPricing) { // state.mockPricing = true // } // if (_config?.skipPricingSignature) { // state.skipPricingSignature = true // } // await LibrarianModule.config( // _config.librarianConfig || { // sourceOfDataForValidation: 'standalone', // sourceOfDataForViews: 'standalone', // }, // ) } }; exports.ConfigModule = { config, getConfigUpdatedStream: () => state.configUpdated$, }; //# sourceMappingURL=config.module.js.map