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

TypeScript dev-utils.web3Factory类代码示例

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

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



在下文中一共展示了web3Factory类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: describe

describe('Assertion library', () => {
    const web3 = web3Factory.create();
    const config = {
        networkId: constants.TESTRPC_NETWORK_ID,
    };
    const zeroEx = new ZeroEx(web3.currentProvider, config);
    describe('#isSenderAddressHexAsync', () => {
        it('throws when address is invalid', async () => {
            const address = '0xdeadbeef';
            const varName = 'address';
            return expect(
                assert.isSenderAddressAsync(varName, address, (zeroEx as any)._web3Wrapper),
            ).to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`);
        });
        it('throws when address is unavailable', async () => {
            const validUnrelatedAddress = '0x8b0292b11a196601eddce54b665cafeca0347d42';
            const varName = 'address';
            return expect(
                assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any)._web3Wrapper),
            ).to.be.rejectedWith(
                `Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 provider`,
            );
        });
        it("doesn't throw if address is available", async () => {
            const availableAddress = (await zeroEx.getAvailableAddressesAsync())[0];
            const varName = 'address';
            return expect(
                assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any)._web3Wrapper),
            ).to.become(undefined);
        });
    });
});
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:32,代码来源:assert_test.ts


示例3: 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


示例4: before

import { web3Factory } from '@0xproject/dev-utils';
import * as chai from 'chai';

import { ZeroEx } from '../src';

import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';

chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();

describe('TokenTransferProxyWrapper', () => {
    let zeroEx: ZeroEx;
    const config = {
        networkId: constants.TESTRPC_NETWORK_ID,
    };
    before(async () => {
        zeroEx = new ZeroEx(web3.currentProvider, config);
    });
    describe('#isAuthorizedAsync', () => {
        it('should return false if the address is not authorized', async () => {
            const isAuthorized = await zeroEx.proxy.isAuthorizedAsync(ZeroEx.NULL_ADDRESS);
            expect(isAuthorized).to.be.false();
        });
    });
    describe('#getAuthorizedAddressesAsync', () => {
        it('should return the list of authorized addresses', async () => {
            const authorizedAddresses = await zeroEx.proxy.getAuthorizedAddressesAsync();
            for (const authorizedAddress of authorizedAddresses) {
                const isAuthorized = await zeroEx.proxy.isAuthorizedAsync(authorizedAddress);
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:token_transfer_proxy_wrapper_test.ts


示例5:

import { web3Factory } from '@0xproject/dev-utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';

const web3ProviderConfig = { shouldUseInProcessGanache: true };
export const web3 = web3Factory.create(web3ProviderConfig);
export const web3Wrapper = new Web3Wrapper(web3.currentProvider);
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:6,代码来源:web3_wrapper.ts


示例6: before

 before(async () => {
     const hasAddresses = false;
     const web3WithoutAccounts = web3Factory.create({ hasAddresses });
     zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
 });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:5,代码来源:token_wrapper_test.ts


示例7: before

 before(async () => {
     web3 = web3Factory.create();
     const pollingIntervalMs = 10;
     web3Wrapper = new Web3Wrapper(web3.currentProvider);
     eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalMs);
 });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:6,代码来源:event_watcher_test.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript utils.promisify函数代码示例发布时间:2022-05-28
下一篇:
TypeScript dev-utils.BlockchainLifecycle类代码示例发布时间: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