• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript utils.logUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript web3-wrapper.Web3Wrapper类代码示例发布时间:2022-05-28
下一篇:
TypeScript utils.intervalUtils类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap