當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript utils.logUtils類代碼示例

本文整理匯總了TypeScript中@0xproject/utils.logUtils的典型用法代碼示例。如果您正苦於以下問題:TypeScript logUtils類的具體用法?TypeScript logUtils怎麽用?TypeScript logUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了logUtils類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: async

 return async () => {
     logUtils.log(`Processing ${tokenSymbol} ${recipientAddress}`);
     const amountToDispense = new BigNumber(DISPENSE_AMOUNT_TOKEN);
     const token = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(tokenSymbol);
     if (_.isUndefined(token)) {
         throw new Error(`Unsupported asset type: ${tokenSymbol}`);
     }
     const baseUnitAmount = ZeroEx.toBaseUnitAmount(amountToDispense, token.decimals);
     const userBalanceBaseUnits = await zeroEx.token.getBalanceAsync(token.address, recipientAddress);
     const maxAmountBaseUnits = ZeroEx.toBaseUnitAmount(
         new BigNumber(DISPENSE_MAX_AMOUNT_TOKEN),
         token.decimals,
     );
     if (userBalanceBaseUnits.greaterThanOrEqualTo(maxAmountBaseUnits)) {
         logUtils.log(
             `User exceeded token balance maximum (${maxAmountBaseUnits}) ${recipientAddress} ${userBalanceBaseUnits} `,
         );
         return;
     }
     const txHash = await zeroEx.token.transferAsync(
         token.address,
         configs.DISPENSER_ADDRESS,
         recipientAddress,
         baseUnitAmount,
     );
     logUtils.log(`Sent ${amountToDispense} ZRX to ${recipientAddress} tx: ${txHash}`);
 };
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:27,代碼來源:dispense_asset_tasks.ts

示例2: _instantiateContractIfExistsAsync

    private async _instantiateContractIfExistsAsync(artifact: any, address?: string): Promise<ContractInstance> {
        const c = await contract(artifact);
        const providerObj = this._web3Wrapper.getProvider();
        c.setProvider(providerObj);

        const artifactNetworkConfigs = artifact.networks[this.networkId];
        let contractAddress;
        if (!_.isUndefined(address)) {
            contractAddress = address;
        } else if (!_.isUndefined(artifactNetworkConfigs)) {
            contractAddress = artifactNetworkConfigs.address;
        }

        if (!_.isUndefined(contractAddress)) {
            const doesContractExist = await this.doesContractExistAtAddressAsync(contractAddress);
            if (!doesContractExist) {
                logUtils.log(`Contract does not exist: ${artifact.contract_name} at ${contractAddress}`);
                throw new Error(BlockchainCallErrs.ContractDoesNotExist);
            }
        }

        try {
            const contractInstance = _.isUndefined(address) ? await c.deployed() : await c.at(address);
            return contractInstance;
        } catch (err) {
            const errMsg = `${err}`;
            logUtils.log(`Notice: Error encountered: ${err} ${err.stack}`);
            if (_.includes(errMsg, 'not been deployed to detected network')) {
                throw new Error(BlockchainCallErrs.ContractDoesNotExist);
            } else {
                await errorReporter.reportAsync(err);
                throw new Error(BlockchainCallErrs.UnhandledError);
            }
        }
    }
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:35,代碼來源:blockchain.ts

示例3: deployAsync

 /**
  * Loads a contract's corresponding artifacts and deploys it with the supplied constructor arguments.
  * @param contractName Name of the contract to deploy. Must match name of an artifact in supplied artifacts directory.
  * @param args Array of contract constructor arguments.
  * @return Deployed contract instance.
  */
 public async deployAsync(contractName: string, args: any[] = []): Promise<Web3.ContractInstance> {
     const contractArtifactIfExists: ContractArtifact = this._loadContractArtifactIfExists(contractName);
     const contractNetworkDataIfExists: ContractNetworkData = this._getContractNetworkDataFromArtifactIfExists(
         contractArtifactIfExists,
     );
     const data = contractNetworkDataIfExists.bytecode;
     const from = await this._getFromAddressAsync();
     const gas = await this._getAllowableGasEstimateAsync(data);
     const txData = {
         gasPrice: this._defaults.gasPrice,
         from,
         data,
         gas,
     };
     const abi = contractNetworkDataIfExists.abi;
     const constructorAbi = _.find(abi, { type: AbiType.Constructor }) as ConstructorAbi;
     const constructorArgs = _.isUndefined(constructorAbi) ? [] : constructorAbi.inputs;
     if (constructorArgs.length !== args.length) {
         const constructorSignature = `constructor(${_.map(constructorArgs, arg => `${arg.type} ${arg.name}`).join(
             ', ',
         )})`;
         throw new Error(
             `${contractName} expects ${constructorArgs.length} constructor params: ${constructorSignature}. Got ${
                 args.length
             }`,
         );
     }
     const web3ContractInstance = await this._deployFromAbiAsync(abi, args, txData);
     logUtils.log(`${contractName}.sol successfully deployed at ${web3ContractInstance.address}`);
     const contractInstance = new Contract(web3ContractInstance, this._defaults);
     return contractInstance;
 }
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:38,代碼來源:deployer.ts

示例4: reject

 rollbar.handleError(err, req, (rollbarErr: Error) => {
     if (rollbarErr) {
         logUtils.log(`Error reporting to rollbar, ignoring: ${rollbarErr}`);
         reject(rollbarErr);
     } else {
         resolve();
     }
 });
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:8,代碼來源:error_reporter.ts

示例5: async

 const noThrowFnAsync = async (arg: T) => {
     try {
         const result = await asyncFn(arg);
         return result;
     } catch (err) {
         logUtils.log(`${err}`);
     }
 };
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:8,代碼來源:error_reporter.ts

示例6: registerPartials

function registerPartials(partialsGlob: string) {
    const partialTemplateFileNames = globSync(partialsGlob);
    logUtils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`);
    for (const partialTemplateFileName of partialTemplateFileNames) {
        const namedContent = utils.getNamedContent(partialTemplateFileName);
        Handlebars.registerPartial(namedContent.name, namedContent.content);
    }
    return partialsGlob;
}
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:9,代碼來源:index.ts

示例7: writeOutputFile

function writeOutputFile(name: string, renderedTsCode: string): void {
    let fileName = toSnakeCase(name);
    if (fileName === 'z_r_x_token') {
        fileName = 'zrx_token';
    }
    const filePath = `${args.output}/${fileName}.ts`;
    fs.writeFileSync(filePath, renderedTsCode);
    logUtils.log(`Created: ${chalk.bold(filePath)}`);
}
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:9,代碼來源:index.ts

示例8: reject

 (contract as any).new(...args, txData, (err: Error, res: any): any => {
     if (err) {
         reject(err);
     } else if (_.isUndefined(res.address) && !_.isUndefined(res.transactionHash)) {
         logUtils.log(`transactionHash: ${res.transactionHash}`);
     } else {
         resolve(res);
     }
 });
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:9,代碼來源:deployer.ts

示例9: resolve

 rollbar.error(err, (rollbarErr: Error) => {
     if (rollbarErr) {
         logUtils.log(`Error reporting to rollbar, ignoring: ${rollbarErr}`);
         // We never want to reject and cause the app to throw because of rollbar
         resolve();
     } else {
         resolve();
     }
 });
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:9,代碼來源:error_reporter.ts


注:本文中的@0xproject/utils.logUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。