当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript web3Factory.getRpcProvider方法代码示例

本文整理汇总了TypeScript中@0xproject/dev-utils.web3Factory.getRpcProvider方法的典型用法代码示例。如果您正苦于以下问题:TypeScript web3Factory.getRpcProvider方法的具体用法?TypeScript web3Factory.getRpcProvider怎么用?TypeScript web3Factory.getRpcProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@0xproject/dev-utils.web3Factory的用法示例。


在下文中一共展示了web3Factory.getRpcProvider方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: reportNodeCallbackErrors

 (async () => {
     const callbackNeverToBeCalled = reportNodeCallbackErrors(done)(
         (logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
             done(new Error('Expected this subscription to have been cancelled'));
         },
     );
     zeroEx.etherToken.subscribe(
         etherTokenAddress,
         EtherTokenEvents.Transfer,
         indexFilterValues,
         callbackNeverToBeCalled,
     );
     const callbackToBeCalled = reportNodeCallbackErrors(done)();
     const newProvider = web3Factory.getRpcProvider();
     zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
     await zeroEx.etherToken.depositAsync(etherTokenAddress, transferAmount, addressWithETH);
     zeroEx.etherToken.subscribe(
         etherTokenAddress,
         EtherTokenEvents.Transfer,
         indexFilterValues,
         callbackToBeCalled,
     );
     await zeroEx.token.transferAsync(
         etherTokenAddress,
         addressWithETH,
         addressWithoutFunds,
         transferAmount,
     );
 })().catch(done);
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:29,代码来源:ether_token_wrapper_test.ts

示例2: it

        it('overrides provider in nested web3s and invalidates contractInstances', async () => {
            // Instantiate the contract instances with the current provider
            await (zeroEx.exchange as any)._getExchangeContractAsync();
            await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
            expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
            expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.not.be.undefined();

            const newProvider = web3Factory.getRpcProvider();
            // Add property to newProvider so that we can differentiate it from old provider
            (newProvider as any).zeroExTestId = 1;
            zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);

            // Check that contractInstances with old provider are removed after provider update
            expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
            expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.be.undefined();

            // Check that all nested web3 wrapper instances return the updated provider
            const nestedWeb3WrapperProvider = (zeroEx as any)._web3Wrapper.getProvider();
            expect(nestedWeb3WrapperProvider.zeroExTestId).to.be.a('number');
            const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getProvider();
            expect(exchangeWeb3WrapperProvider.zeroExTestId).to.be.a('number');
            const tokenRegistryWeb3WrapperProvider = (zeroEx.tokenRegistry as any)._web3Wrapper.getProvider();
            expect(tokenRegistryWeb3WrapperProvider.zeroExTestId).to.be.a('number');
        });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:24,代码来源:0x.js_test.ts


注:本文中的@0xproject/dev-utils.web3Factory.getRpcProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。